daniyalahmad
daniyalahmad

Reputation: 3843

Change WooCommerce price per product

I want to change per product price in WooCommerce. I am looking for some hook to do it. Actually i am looking to discount product 10%. I want to do it pragmatically.

function woo_my_custom_message($price_html) {
   $price = trim($price_html);
   $price = (int) $price;
   return ($price*10)/100;
}
 add_filter( 'woocommerce_cart_item_price', 'woo_my_custom_poa_message' );

Upvotes: 0

Views: 199

Answers (1)

James Jones
James Jones

Reputation: 3899

The filter you're looking for is woocommerce_get_price. So your code will be something like:

function my_custom_price($price, $product) {{      
   return $price * 0.9;
}

add_filter( 'woocommerce_get_price', 'my_custom_price', 10, 2);

Upvotes: 1

Related Questions