Back in browser

I have a question regards the products v4.21, if i land on the product page and then decide to press “back” in my browser it will take me to the previous page which in the case was the homepage. (fine) BUT…if i select a variation , then another variation (maybe to check stocks) when i then press back, it only takes me to the previous variation and not the home page, is this normal cs cart behavior.?

i think The better behaviour would be:

  • Continue updating the URL so the chosen variation can be bookmarked or shared.
  • Replace the current product history entry instead of adding a new one.
  • One press of Back would then return the customer to the homepage or category page they came from.

Hello

Yes, thats how it works out of the box. Every variation switch adds a new entry to the browser history, so Back walks through the variations first.

If the variations are shown as one product, the selectors have the cm-history class (product_variations/hooks/products/product_option_content.pre.tpl). Remove it in your theme and Back goes straight to the previous page, but the URL wont change when switching anymore. Variations set up as separate products are normal page loads, so nothing to tweak there.

Keeping the URL updated with replaceState isnt a setting, it needs a small JS change.

Best regards
Robert

2 Likes