Woocommerce product bundles Bug adding to cart
Hello,
I am trying to create a website with bundles but i believe there is a bug with the official woocommerce product bundles plugin.
When i try to add a bundle to the cart, the website adds 2 to the cart..
You can see here:
But this only happens in the product page.. in the shop page or homepage it is correct.
Can you help me here?
Thank you
Comments
Other bug with the same plugin..
https://stage.webcarv.com/product/simple-couch-2/
When i check the checkbox for the bundle and click on add to cart it was suppose to add both products to the cart but that is not happening, it only adds the main product.
If you want i can give you access to this website.
Hi,
Please go to WooCommerce -> Settings -> Products, and disable the AJAX option:
After that, check if the problems persist.
Thanks
Hello,
Thank you for your response.
That was already active and do not work.
I found a way to fix the problem of the bundles with the checkbox but the first bug still persists. (duplicated quantity adding packs to the cart.)
Solution for the second problem:
add_action('woocommerce_add_to_cart', function($cart_item_key, $product_id, $quantity) {
static $adding = false;
if ($adding || empty($_POST)) {
return;
}
$bundle_sells = get_post_meta($product_id, '_wc_pb_bundle_sell_ids', true);
if (empty($bundle_sells) || !is_array($bundle_sells)) {
return;
}
foreach ($bundle_sells as $index => $addon_product_id) {
$field_name = 'bundle_selected_optional_' . ($index + 1);
if (!isset($_POST[$field_name])) {
continue;
}
$adding = true;
WC()->cart->add_to_cart((int) $addon_product_id, $quantity);
$adding = false;
}
}, 20, 3);
Forget! It's solved.. option disabled!
However there is any way to do that with the ajax active?
Some plugins require reloading the product page to properly add a product to the cart, so if you need this plugin on your website, then the AJAX option must remain disabled.
Best regards