Question

I am new to Wordpresss and Woocommerce. I have a web site which uses "product bundle" extension, If I add a product to cart which is already in the cart then it should not updated the quantity and it should be added as new product to the cart as per below scenario.

Product Architecture

In a bundle "A", I added products of - ABC, DEF and GHI and set limit to 2.

Each products (ABC, DEF and GHI) has product variations - X and Y as add on .

Add to Cart

First time an user select a product ABC for variation X with Quantiy 3 Second Time an user select a product DEF for variation Y with Quantity 3

Shopping Cart

In shopping it should show as, product ABC quantity as 3 with variation X and in another row product ABC quantity as 3 with variation Y.

BUT it is showing as product ABC quantity as 6 with variation X.i.e Variation Y is not included in the cart.

Please help me to fix this.

No correct solution

OTHER TIPS

I fixed the issue by creating new row in shopping cart for every click in "Add to Cart " button. I mean, if a user click on the "Add to cart" button it will create new product item in the shopping cart even the same product available in shopping bag. i.e NO UPDATE in product in QUANTITY.

In the function add_to_cart in class-wc-cart.php file (wp-content\plugins\woocommerce\classes) it create id for product in shopping cart as

// Generate a ID based on product ID, variation ID, variation data, and other cart item data
$cart_id = $this->generate_cart_id( $product_id, $variation_id, $variation, $cart_item_data );

I change that to

// Generate a ID based on product ID, variation ID, variation data, and other cart item data
$cart_id = $this->generate_cart_id( $product_id.'_'.date('Y-m-d H:i:s', time()), $variation_id, $variation, $cart_item_data );

and itis working fine now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top