WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
filter woocommerce_add_cart_item not working (1 post)

  1. alancf
    Member
    Posted 1 year ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic