Support » Plugin: Stock Locations for WooCommerce » Product Page Infinitely Reloads

  • I have been having an issue where sometimes going to a product page results in a double reload. Sometimes though, the reloads never stop. After much debugging, I have narrowed it down to your plugin. I have switched my theme to storefront and disabled all plugins except yours and woocommerce and the issue still happens.

    I looked through your code and I believe the issue starts in the file /src/helpers/helper-slw-frontend.php and in this block of code:

    // update stock and stock status first to not show wrong data to customers
    	$product_locations_total_stock = SlwProductHelper::get_product_locations_stock_total( $product_id );
    	$product_wc_stock              = $product->get_stock_quantity();
    	if( $product_wc_stock != $product_locations_total_stock ) {
    		update_post_meta( $product_id, '_stock', $product_locations_total_stock );
    		SlwProductHelper::update_wc_stock_status( $product_id );
    		// refresh page
    		echo("<meta http-equiv='refresh' content='1'>");
    	}

    When I comment out the echo refresh line the reloads stop. The total stock quantity is wrong though. I’m not sure why but it seems as though sometimes it can’t update the total stock and gets stuck in an infinite reload loop.

    • This topic was modified 2 months, 3 weeks ago by nickdill.
    • This topic was modified 2 months, 3 weeks ago by nickdill.
Viewing 4 replies - 1 through 4 (of 4 total)
  • rivalink

    (@rivalink)

    Am also getting this happening causing 502 Timeouts on my website as products use up all resources reloading… Is there a fix for this?

    I also have the same problem. i use elementor pro and wp all import.

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    It reloads when stock location stock value is different from the product stock value. Can you please confirm if it is happening with simple product or the variable? Because usually we don’t notice but variable products have different IDs for variations and there can be a room for the improvement. As soon as you will respond, I will be able to fix it.

    this is the problem Simple product.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.