Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 104029

alancf on "filter woocommerce_add_cart_item not working"

$
0
0

Hi,

I'm trying to modify the price of a product before it is added to the cart. I'm using the filter 'woocommerce_add_cart_item', but I can't get it to work. Here's my code:

add_filter( 'woocommerce_add_cart_item', 'change_product_price_in_cart', 99, 1 );
function change_product_price_in_cart( $cart_data ) {
	$cart_data[ 'data' ]->price = 999;
	return $cart_data;
}

But in the cart all I see is the original price of the product. Am I missing something?

http://wordpress.org/extend/plugins/woocommerce/


Viewing all articles
Browse latest Browse all 104029

Trending Articles