Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3773527
Bug when adding products to cart
Open

Comments

  • Willem started the conversation

    Hello,


    The plugin has a bug when adding smart bundles to the cart. There is a possibility that a key gets generated, when building the "items" in the WC_Product_Woosb class. This results in an error, because it will check based on that key that the product exists in the pruchasable products array.

    1929031971.png

    The key should only be generated when the data[1] value is the quantity of the product. This is not the case in this situation. The product is stored as 75116/6691328353230/1,etc in the database. As you can see is the data[2] value the quantity. This shows that there is a possibility that the data[1] value is numeric.

    I think that the solution is to check that the data[2] key is set, see code below. This should be replaced at class-product.php on line 515, for anyone who also has this issue.

    if ( isset( $data[1] ) ) {
        if ( !isset( $data[2] ) && is_numeric( $data[1] ) ) {   
            $key = WPCleverWoosb_Helper()->generate_key();
            $qty = (float) $data[1];
        } else {
            $key = $data[1];
            $qty = (float) ( $data[2] ?? 1 );
        }
    } else {
        $key = WPCleverWoosb_Helper()->generate_key();
        $qty = 1;
    }

  •  1,281
    Dustin replied

    Hi Willem,

    Thanks so much for your contribution!

    I added this code to our plugin. It'll be available in the next updated version.

    Best regards,
    Dustin