• WordPress 6.7
    Woocommerce 9.7
    WPC Product Bundles 8.2.1

    After adding a bundle to the cart, it appears empty, event if adding another product.
    It seems there is a issue with how the product bundle quantity is handled as a float instead of an integer.
    Therefore, in the normalize_cart() function the normalized quantity of 1 cannot be type equal to the quantity of 1.0 leading to calling set_cart_item_quantity. But the item quantity is not editable (=false) throwing an exception with the error message The quantity of %1$s cannot be changed.

    /**
    * Normalizes the cart by fixing any quantity violations.
    */
    public function normalize_cart() {
    $quantity_limits = new QuantityLimits();
    $cart_items = $this->get_cart_items();

    foreach ( $cart_items as $cart_item ) {
    $normalized_qty = $quantity_limits->normalize_cart_item_quantity( $cart_item['quantity'], $cart_item );

    if ( $normalized_qty !== $cart_item['quantity'] ) {
    $this->set_cart_item_quantity( $cart_item['key'], $normalized_qty );
    }
    }
    }

    I managed to fix the issue on our website by modifying cart items to cast quantity as integer through the woosb_minify_items filter

    add_filter('woosb_minify_items', 'woosb_minify_items_cast_quantity_to_int'], 10, 2);
    function woosb_minify_items_cast_quantity_to_int($minify_items): array
    {
    return array_map(function($item) {
    $item['qty'] = (int) $item['qty'];
    return $item;
    }, $minify_items);
    }

    Don’t know why item quantity is a float in your plugin but in our case it makes no sense so casting to integer seems ok.

Viewing 1 replies (of 1 total)
  • Plugin Support Janilyn T

    (@janilyn409)

    Hi @leup ,

    There might be another plugin conflicting with our plugin on your site.

    If you want to find out the source of this issue, you can:

    • Deactivate all other plugins, except WooCommerce and our WPC plugins. Check the functionality to see if it’s working or not.
    • Reactivate other plugins one by one to find the source of the conflict.
    • Change to our WPCstore theme or any other WooCommerce specialized theme to check.

    Unfortunately, we do not have any technical support agent available on this forum to help you check that out.

    My guess is that this might be a conflict with the cart widget. If you are using a block-based cart, it might be the reason. The subproducts are not allowed to be edited anyhow once they are added to the cart alongside the main bundle. Any theme or template that allows the edition of all items’ quantity and removability can cause conflicts with our plugin.

    Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Cart Block appears empty after adding a bundle’ is closed to new replies.