• Resolved nickdill

    (@nickdill)


    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 3 years, 6 months ago by nickdill.
    • This topic was modified 3 years, 6 months ago by nickdill.
Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    @tomkolp hi again, I am studying this issue again and found something confusing. Apparently product page is allowing and expecting only simple products and in case location stock and product stock values are different so it updates product stock according to the location stock and immediately refresh the page. Here is the point.

    Why is it refreshing infinitely?
    As I mentioned above, this page is expecting only simple products but there is function which is allowing variable products as well to use this section. Variable product has variations and each variation has a different ID as a product ID. On each refresh, this function might be checking the variation stock and updating the product stock. This can be a bug as stock value remains unchanged even after updating after refresh.

    I am releasing a new version with troubleshooting log, hopefully we can narrow down this issue.

    So you will see the following notice instead of refreshing page infinitely “Stock value updated. Please refresh this page.”. It means that you are facing the same issue and in the background I will log the traces to reach the root cause.

    • This reply was modified 3 years, 3 months ago by Fahad Mahmood.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Product Page Infinitely Reloads’ is closed to new replies.