Jump to content

Not just any back button


stretch

Recommended Posts

I've searched and found solutions for back buttons, but they don't work for my scenario.

Use Case:

Step 1:User clicks into product product_img_link, either from the HOME page (no category) OR clicks into the product via a category page or subcategory page.

Step 2: User selects a combo. Price updates on product page. User selects another combo (we could have 20 combos on a single product).

Step 3: User clicks browser back button and wants to get back to the "previous page" Example: Category Bla Page 5 is where the product he/she clicked into is. When they click the back button, currently it steps them back thru EVERY combination they selected, finally back to the "previous page" ie Page 5 of some category.

Back button I implemented takes you back to the category, however, only appears when you come from a "category page" not the HOME page. As well, it does not take you to the page in the category you were browsing from ie page 5.

Does this make sense? I'm looking for a solution that takes me back to the previous page if possible. I'm not scared of some coding.

Link to comment
Share on other sites

Or create function from custom.js

function goMyBackButton() {
  window.history.back()
}

 

add tpl file:

<a href="#" onclick="goMyBackButton()">Back to previous page</a>

 

 

Edited by Guest (see edit history)
Link to comment
Share on other sites

  • 3 years later...

Hello,
I know the post is a bit old, but maybe someone else is facing this problem.
I had this problem before with the initial versions of 1.7, but it was solved with the following updates.
Now I installed version 8 and, SURPRISE, the same problem again.
I initially thought it was a problem with the theme, but it's the same with the Classic theme.
After several hours of searching in vain, the SOLUTION, now that I have solved it, seems quite trivial:
in the "themes/core.js" file look for

window.history.pushState({id_product_attribute:e.id_product_attribute,form:n}

and replace

window.history.pushState

with

window.history.replaceState

 

  • Thanks 1
Link to comment
Share on other sites

  • 6 months later...
On 8/26/2023 at 9:27 AM, MihaiB1 said:

Hello,
I know the post is a bit old, but maybe someone else is facing this problem.
I had this problem before with the initial versions of 1.7, but it was solved with the following updates.
Now I installed version 8 and, SURPRISE, the same problem again.
I initially thought it was a problem with the theme, but it's the same with the Classic theme.
After several hours of searching in vain, the SOLUTION, now that I have solved it, seems quite trivial:
in the "themes/core.js" file look for

window.history.pushState({id_product_attribute:e.id_product_attribute,form:n}

and replace

window.history.pushState

with

window.history.replaceState

 

Good bless you bro.

 

So much thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...