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

Sergiu Ghita on "[Plugin: WooCommerce - excelling eCommerce] How to hook just before add to cart (class-wc-cart)"

$
0
0

Hello.

I want to run a function that compares the product i am about to use with the products that are already in the cart.

If there is a conflict between the products, i don't want the product to be added and print an error.

A pure example:
If i add a product "left shoe" and then add the product "both shoes", i want to print an error instead of adding the "both shoes": Sorry, but you can't add both shoes if you've added left shoe to the cart. If you want to buy "both shoes", please first remove "left shoe".

I've looked at class-wc-cart.php and i found an action hook at line 811, but it's too late! It's after the product has been added

"do_action( 'woocommerce_add_to_cart', $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data );"

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


Viewing all articles
Browse latest Browse all 104029

Trending Articles