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

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.