• Chritchan

    (@chritchan)


    Hi !
    I’m using WooCommerce Product Bundles and the Quantity in Carts didn’t reduce. Any idea of how to manage this type of products?

    Thanks 😀

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author James Golovich

    (@jamesgol)

    I’ve never used the Product Bundles plugin so I don’t know for sure how it handles the actual products. When you add a bundle does it show an inventory reduction on an individual product or the bundle?

    I suspect this would require some code added specific to that plugin.

    I found this action in the (great) plugin code:
    wc_csr_before_remove_expired_item

    Based on this, if an item is expired that’s part of a bundle, it’s possible to remove the bundle is part of too. Code below also shows how this can remove composite products too.

    function remove_expired_cart_item_parent($cart_id, $cart){
    if (null === $cart) {
    // This should never happen, but better to be safe
    $cart = WC()->cart;
    }

    if (isset($cart->cart_contents[ $cart_id ][‘composite_parent’])){
    // If belongs to composite, remove
    $cart->remove_cart_item( $cart->cart_contents[ $cart_id ][‘composite_parent’] );
    WC()->session->set(‘cart’, $cart->cart_contents);
    }

    if (isset($cart->cart_contents[ $cart_id ][‘bundled_by’])){
    // If belongs to bundle, remove
    $cart->remove_cart_item( $cart->cart_contents[ $cart_id ][‘bundled_by’] );
    WC()->session->set(‘cart’, $cart->cart_contents);
    }

    return;
    }

    Could be cleaner but you get the idea.

    Plugin Author James Golovich

    (@jamesgol)

    @ap88 I see this removes products but is the stock quantity properly tracked for each product belonging to a bundle?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Product Bundles didn’t reduce’ is closed to new replies.