Seen this issue highlighted a few times in the wordpress help forum, so I wanted to mention it here too.
I have created a pack. In this pack people can select any 3 products.
Someone can select 3 of the same item which is exactly what I want.
However, if I have 2 x in stock of the item, and they try to select the same flavour for all 3 componants, it throws a fatal error on the website for them.
Is there a way around this? The point in the pack is people can mix and match and get a discount, so I don't want to disable the option to buy 3 x of the same item if they want. I just want some kind of error to come up instead to say only 2 x of this item in stock, please select a different one (as an example)
For your information, in composite products, our plugin can only check the stock of component products when the Add to Cart button is pressed. So it is not until customers press the Add to Cart button that they receive an alert or error.
As composite products can pull multiple products from different sources, it would take up resources of your site if our plugin checks stocks too frequently of all added products when buyers are choosing items. Unlike in smart bundles or smart grouped products, each subproduct is a single item so it's easier to do that. With composite products, it would slow down the site when loading the page and checking stocks of all components.
We will try to find a way to solve that, but for now, we haven't come up with any solution, unfortunately.
I only need it so when 'add to cart' is pressed, the site doesn't give a fatal error. This happens if there's not enough stock across the composite products selected, as outlined in my first message.
2022-01-18T17:38:17+00:00 CRITICAL Uncaught Error: Call to a member function get_tax_class() on null in /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php:225
Stack trace:
#0 /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(651): WC_Cart_Totals->get_items_from_cart()
#1 /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(143): WC_Cart_Totals->calculate_item_totals()
#2 /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(134): WC_Cart_Totals->calculate()
#3 /wp-content/plugins/woocommerce/includes/class-wc-cart.php(1398): WC_Cart_Totals->__construct(Object(WC_Cart))
#4 /wp-includes/class-wp-hook.php(301): WC_Cart->calculate_totals()
#5 /wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(NULL, Array)
#6 /wp-includes/plugin.php(470): WP in /wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php on line 225
Could you please provide me with a link to your published composite product for checking thew frontend? There are many possible elements that cause a fatal error, mostly a conflict with third-party plugins or theme.
After receiving your information, I'll proceed to the next step.
Seen this issue highlighted a few times in the wordpress help forum, so I wanted to mention it here too.
I have created a pack. In this pack people can select any 3 products.
Someone can select 3 of the same item which is exactly what I want.
However, if I have 2 x in stock of the item, and they try to select the same flavour for all 3 componants, it throws a fatal error on the website for them.
Is there a way around this? The point in the pack is people can mix and match and get a discount, so I don't want to disable the option to buy 3 x of the same item if they want. I just want some kind of error to come up instead to say only 2 x of this item in stock, please select a different one (as an example)
Hi Robert,
Thanks for contacting us here.
For your information, in composite products, our plugin can only check the stock of component products when the Add to Cart button is pressed. So it is not until customers press the Add to Cart button that they receive an alert or error.
As composite products can pull multiple products from different sources, it would take up resources of your site if our plugin checks stocks too frequently of all added products when buyers are choosing items. Unlike in smart bundles or smart grouped products, each subproduct is a single item so it's easier to do that. With composite products, it would slow down the site when loading the page and checking stocks of all components.
We will try to find a way to solve that, but for now, we haven't come up with any solution, unfortunately.
Best regards.
Janilyn T. - WPClever Support Agent
Hi,
I don't need it to check stock more frequently.
I only need it so when 'add to cart' is pressed, the site doesn't give a fatal error. This happens if there's not enough stock across the composite products selected, as outlined in my first message.
Attached a screenshot showing the error.
The same issue was mentioned here about a year ago: https://wordpress.org/support/topic/error-with-several-same-components-when-not-enough-stock/
Error log:
Hi Robert,
Thank you for the feedback.
Could you please provide me with a link to your published composite product for checking thew frontend? There are many possible elements that cause a fatal error, mostly a conflict with third-party plugins or theme.
After receiving your information, I'll proceed to the next step.
Best regards.
Janilyn T. - WPClever Support Agent