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

Okay
  Public Ticket #2217295
Fatal error when added product to the cart because bundle product has no bundled products selected
Closed

Comments

  •  1
    Jasom started the conversation

    Here is error message recived when I try to add product to the cart:

    Fatal error: Uncaught Error: Call to a member function get_name() on bool in /var/www/mystore.com/htdocs/wp-content/plugins/woo-product-bundle/index.php:1653 Stack trace: #0 /var/www/mystore.com/htdocs/wp-includes/class-wp-hook.php(290): WPcleverWoosb->woosb_add_to_cart_validation(true, 1786) #1 /var/www/mystore.com/htdocs/wp-includes/plugin.php(206): WP_Hook->apply_filters(true, Array) #2 /var/www/mystore.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-form-handler.php(776): apply_filters('woocommerce_add...', true, 1786, 1) #3 /var/www/mystore.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-form-handler.php(750): WC_Form_Handler::add_to_cart_handler_simple(1786) #4 /var/www/mystore.com/htdocs/wp-includes/class-wp-hook.php(288): WC_Form_Handler::add_to_cart_action('') #5 /var/www/mystore.com/htdocs/wp-includes/class-wp-hook.php(312): WP_Hook->apply_filters(NULL, Array) #6 /var/www/mystore.com/htdocs/wp-includes/plugin.php(478): WP_Hook->do_action(Array) #7 /var/www/mystore.com/htdocs/wp-settings.php(545): do_action('wp_load in /var/www/mystore.com/htdocs/wp-content/plugins/woo-product-bundle/index.php on line 1653

    Error appears when there is no product selected in product added to the cart. Basically it is an admin error – display to the user bundle-product without bundled products selected but plugin should somehow handle such situation (not with fatal error message).

    Message like – Bundle is without products – would be OK.

    Product Save / Update with no products in bundle should not be validated, now it does.

    In admin > Woocommerce > Producs table should by a note after product title "product has no bundled products selected"

    see link https://wordpress.org/support/topic/fatal-error-when-added-product-to-the-cart/

  •  925
    Dustin replied

    Hi,

    By default, if buyer don't choose any product, they can't add the bundle to the cart. You can try with https://demo.wpclever.net/woosb/product/smart-bundle-02/ (https://prnt.sc/pybs7y).

    If it doesn't work on your website, may be have the conflict with the theme or other plugins. Please send me the bundle link then I can check it first.

    For more quickly, please send me your website info (wp-admin link, username, password) then I can check and fix this problem for you. You also can create a dev/staging site with the same issue then I'll work on it.

    Best regards,
    Dustin

  •   Jasom replied privately
  •  925
    Dustin replied

    I still can't open this link https://prnt.sc/pyg1whfrown.png

    Best regards,
    Dustin

  •   Jasom replied privately
  •  925
    Dustin replied

    The bundle need to have pre-defined products. I see you didn't add any product to the bundle https://prnt.sc/pywtej

    I added some products and the result https://www.eates.tk/product/bundle-products-type-allows-to-save-bundle-without-products-selected/

    Best regards,
    Dustin

  •  1
    Jasom replied

    > I see you didn't add any product to the bundle https://prnt.sc/pywtej

    After I wrote about it, you finally see it. Good, good... I feel we are going somewhere. With level of your sharpness we could have it on Monday next week.

    Next question: What else I wrote about?

  •  925
    Dustin replied

    Sorry about that!

    I changed the code for you https://prnt.sc/p
    You can test again here https://www.eates.tk/product/smart-bundle-with-ugly-error/

    We'll also fix this issue on the next updated version soon.

    Best regards,
    Dustin

  •  1
    Jasom replied

    So it works. Change message to "bundle is empty and cannot be added to the cart" instead of "You cannot add this bundle to the cart.". So admin can easily figure out where the problem is.

    Also see this https://www.eates.tk/product/empty-smart-bundle/  - Empty bundle should not be validated on product save / update. I - as admin / shop manager - should be not able to create empty smart bundle.

    Also use "post state" to inform admin / shop manager if existing "smart bundles" are empty, see the code https://wordpress.stackexchange.com/a/240088

    Here is a print what post-state is https://bit.ly/2XtZZYw

  •  925
    Dustin replied

    Thank you so much!

    We'll add the validate and state for the bundles to the next updated version and release this week.

    Best regards,
    Dustin

  •  1
    Jasom replied

    Make sure you will add also post-state message. There will be dozen stores with same problem the admin has no info about.

    You can close the issue. Thank you.