• I’m using Woocommerce Product Add-ons plugin and this plugin.

    However, I’m facing a very strange issue. If a product has global addons, 1 in 20 times the global addons are not added to the cart.

    I found that when this happens, the function get_posts() (in WC product add-ons plugin) returns an empty array when it should return the global addons posts IDs. This only happens on an ajax call randomly (1 in 20 times aprox).

    I confirmed that the arguments passed to the functions are the same on both page load and Ajax call, even when the issue occurs.

    Any idea why get_posts() is behaving like this?

Viewing 1 replies (of 1 total)
  • Thread Starter maurosp91


    I finally found the cause and want to share it, so it might help others.

    The issue was due to product addons module of dokan pro plugin.

    add_action( ‘pre_get_posts’, [ $this, ‘render_vendor_global_addons’ ], 99 ); in class-frontend.php file.

    The function render_vendor_global_addons() only checks for $_REQUEST[‘add-to-cart’]. However, when it is added via AJAX, “add-to-cart” becomes “product_id”. So get_posts() returns an empty array everytime.

    And the randomness was because lite speed cache was fixing this issue most times. A downside of this was that the issue was very hard to identify and reproduce.

    Hope it helps others.


Viewing 1 replies (of 1 total)
  • The topic ‘Global addons not added to cart 1 out of 20 times’ is closed to new replies.