Infinite Loop When Adding To Cart
-
Hello,
Thank you for creating this plugin! It has served us well, allowing us to add required products to the cart when corresponding items are added. The plugin has been working great until recently. I’m not exactly sure which version or what date this started occurring on. We have an infinite loop issue when customers are adding to the cart.
Customers on a client site are attempting to add a product to their cart but the website is timing out. I determined the issue is tied to the Force Sell for WooCommerce plugin. I came up with a temporary work-around which I will share below.
If we deactivate Force Sell for WooCommerce the issue does not occur. We have a variable Membership/Subscription product. We have added conditions to force sell another Simple product when those variations are added to the cart. When the variable product is added to the cart, the site times out as I mentioned earlier. While debugging, I determined that Force Sell for WooCommerce was stuck in an infinite loop during the WooCommerce “add_to_cart” actions. Note that we do have some customized logic in a plugin for our client’s particular use case. However, deactivating our customizations did not help.
As we needed to get the site functional as soon as possible, I determined that if I removed a set of actions and filters before Force Sell for WooCommerce called the WooCommerce add_to_cart() function, the issue was resolved.
I added the following code before the WC()->cart->add_to_cart() call on line 225 in includes/force-sell-types/add_force_sell.php:
remove_action( 'woocommerce_add_to_cart', array( $this, 'add_to_cart' ) );
remove_filter('berocket_force_sell_check_result_add_to_cart', array($this, 'check_result_add_to_cart'));
remove_filter('berocket_force_sell_check_result_other', array($this, 'check_result_other'));I know this is a temporary work-around. I’m not sure if this is even the correct fix, but it appears to be working on our client site. I’d be happy to share a staging environment with you, including login details, via email if it helps. Let me know if you need clarification on anything.
Thank you!
You must be logged in to reply to this topic.