Since update: Error when viewing cashed product pages with attributes in the URL
-
Hello WooCommerce team.
We have updated WooCommerce today and we have noticed a new bug.
If we call up a product page of a variable product and there is an attribute in the URL (?attribute_pa_*), then there is a problem.
WooCommerce seems to have changed its own behavior.
- The parameters preselected via the URL are now marked as “selected” on the server side in the “wc_dropdown_variation_attribute_options” function.
- Previously, I think this was done dynamically in the frontend via JavaScript.
We ignore the attributes in the query due to far too high time to first byte (which damaged our Google Ads quality factor) in our cache guidelines.
This necessary action with the current version of WooCoomerce results in additional product page views, which may have a different pre-selected attribute, being displayed with incorrectly pre-selected option values.We used to be able to cache page views with query without any problems because no option in select had the “selected” attribute. And even if it did: WooCommerce’s frontend JavaScript would have saved us because it corrects dynamically.
Now we cache the server-side result, which unfortunately marks an option value with “selected” and WooCommerce no longer corrects it frontend via JavaScript.
We would now have to choose between: People coming via ads, showing the wrong product OR disabling cache and suffering way too high time to first byte.
It would be nice if the WooCommerce team at least supplemented the old behaviour to the extent that the URL state is dynamically synchronized with the form state once during page load.
To clarify with an example:
Before:
- Page call 1: ?attribute_pa_color=red => Page is cached neutrally without preselection, JavaScript preselects the option “red”. User sees “red”.
- Page call 2: ?attribute_pa_color=blue => Page is loaded neutrally from the cache without preselection, JavaScript preselects the option “blue”. User sees “blue”.
Everything is correct.
Now:
- Page call 1: ?attribute_pa_color=red => Page is cached with the server side generated preselection of the option “red”. User sees “red”
- Page call 2: ?attribute_pa_color=blue => Page is loaded from the cache with the preselection of the option “red”, JavaScript does not select the option “blue”. User sees “red”.
This is wrong. “blue” is expected.
We would be very happy if you could check the error, solve it and provide an update.
- You must be logged in to reply to this topic.