Header menu

_________________________________________________________________________________
Showing posts with label custom price. Show all posts
Showing posts with label custom price. Show all posts

Saturday, 19 October 2013

Add custom price to product in woocommerce

Woocommerce saves its product price in a dynamic database table in serialized form which are present on cart..... Hence we cannot edit it directly ...

So , to add your custom price use below code:

function add_custom_price( $cart_object) {

  $custom_price = 1151; // This will be your custome price 

  foreach ( $cart_object->cart_contents as $key => $value ) {
            $value['data']->price = $my_sess['price'];
        }
    } 
 add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' )
;

 If you dont know where to add this code ... Add it at the top of wocommerce-functions.php file present in wocommerce plugin
 Yippe .. Now you got your custom price for the products :)