Drupal Ubercart hook after complete purchase order object saved.

Ubercart is the best and highly used e-commerce framework for Drupal. Ubercart provides awesome hook functionality. Using hook we can able to change some functionality without touching or modify the Ubercart code file.

Continue reading Drupal Ubercart hook after complete purchase order object saved.

Drupal 7 handle redirect URL after user registerd.

How to handle the redirect URL after user completed the registration process on Drupal7 Custom module. After completing the registration process by default Drupal redirect user to home page. Let’s see how we can handle the redirect URL after complete the registration process.

Continue reading Drupal 7 handle redirect URL after user registerd.

WooCommerce add to cart products with customized price using hooks

Many times we want to sell the product with the custom price. So if you have many products and you want to set custom price only for 10 products for 1 hours. it’s hard to change price of the product from WooCommerce admin panel.

We can change the price of the product without changing the code of core module or without editing the price for the product from WooCommerce admin panel using WordPress Hooks.

So let’s see how we can use WooCommerce Hooks for changing the price of the product.

Just copy below code on functions.php file.

add_filter('woocommerce_get_price','change_price', 10, 2);
add_filter('woocommerce_get_regular_price','change_price', 10, 2);
add_filter('woocommerce_get_sale_price','change_price', 10, 2);


function change_price($price, $productd){
     if($productd->id == '1'){
        $price = "150";
     }
     return $price;
}

So, As per above example, we set the “150” price for the product that has 1 id. So using above example you can set price without editing product or change the WooCommerce code.

If you face any issue after using above code please write comment below.