New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh fragments infinite loop with multisite #10940
Comments
Is WC activated per site or across the network... |
@mikejolley in both cases |
There is a doc about this somewhere but I cannot find it. I think you need a unique cookie per site. Possibly related https://tommcfarlin.com/resolving-the-wordpress-multisite-redirect-loop/ |
It doesn't help, is it not plugin related? Maybe you need to add some blog id value to the cart hash? if ( 'wc_cart_hash' === e.originalEvent.key && localStorage.getItem( 'wc_cart_hash' ) !== sessionStorage.getItem( 'wc_cart_hash' ) ) { |
I see infinite loops for this same fragment too, but on ordinary single site installs. I've seen it several times whilst testing extensions I'm working on. I've not managed to get it down to a list of reproducible steps. It seems to be in core - a few days ago, I de-activated all other extensions, and it still happened. It's somehow related to multiple tabs open. I tweaked that bit of JavaScript to log to the console both localStorage.getItem( 'wc_cart_hash' ) and sessionStorage.getItem( 'wc_cart_hash' ) - and it was logging the same values for each of them endlessly (i.e. neither value changed to become equal to the other). |
@coderkevin I wonder if this is one you maybe want to look into? The code in question is in cart-fragments.js:
This is supposed to update the cart widgets if you add to cart in another tab. I guess this needs some form of protection against infinite loops if one tab updates and then triggers another etc etc |
I started looking into this today and got a multi-site test environment set up on this on our master branch. I have reproduced the issue in my test environment and will look at solving it tomorrow. Thanks! |
This is fixed in PR #10983 |
EXPLANATION OF THE ISSUE
When I have a few stores created as a multisite with woocommerce installed, after adding product to cart AJAX request is initiated (wc-ajax=get_refreshed_fragments). If I have another tab opened (using google chrome) with the other store (from my multisite) another request starts inside this tab. So if I have two or more tabs with different stores opened in google chrome these requests are calling infinetely. I have tested with Storfront theme too. You can check how it works on this theme on themeforest (it has multisite). Just open two versions in different tabs and inspect it's requests after adding something to cart.
http://woodstock.temashdesign.com/electronics/
http://woodstock.temashdesign.com/watch/
Here is a screenshots of how it looks like
https://gyazo.com/1a6e53416603bd0a1b60359a363bec71
I guess it is because of this part of code
// Refresh when storage changes in another tab $( window ).on( 'storage onstorage', function ( e ) { if ( 'wc_cart_hash' === e.originalEvent.key && localStorage.getItem( 'wc_cart_hash' ) !== sessionStorage.getItem( 'wc_cart_hash' ) ) { $.ajax( $fragment_refresh ); } });
Because cart hashs are not equal between these two multisite.
Please give me some respond about this, maybe I do something wrong? If it is really a plugin issue I can try to prepare PR to fix this.
STEPS TO REPRODUCE THE ISSUE
SYSTEM STATUS REPORT
The text was updated successfully, but these errors were encountered: