WooCommerce hook “add_to_cart” does not send quantity

I’m subscribing to a woocommerce hook and it’s supposed to include the $quantity argument in the callback function but it looks like it’s never sent.

add_action('woocommerce_add_to_cart', array(&$this, 'track_cart_add'));

function track_cart_add($cart_item_key, $product_id = 0, $quantity = 1, $variation_id = null, $variation = null, $cart_item_data = null) {
 // code here
}

Quantity is always one and if I print out the arguments, it shows that the function has only one argument which is the first one ($cart_item_key). Am I missing something?

Read More

The woocommerce_add_to_cart event is triggered here: http://docs.woothemes.com/wc-apidocs/source-class-WC_Cart.html#948

Related posts

1 comment

  1. Have you tried adding the priority and accepted args arguments?

    Try this

    add_action('woocommerce_add_to_cart', array(&$this, 'track_cart_add'), 10, 6);
    
    function track_cart_add($cart_item_key, $product_id = 0, $quantity = 1, $variation_id = null, $variation = null, $cart_item_data = null) {
     // code here
    }
    

Comments are closed.