Build a URL that adds a product and then redirects back to /collections/all?

Highlighted
New Member
3 0 0

Hi,

 

I have this URL right now:

https://shop.example.com/cart/add?id=31430858440768?redirect=/collections/all


What I'm trying to get it to do is add this particular item to the cart, then take the user back to the main store to shop some more. Right now, this URL will add the item and take the user to the cart without redirecting them back to my collections page.

Is there anyway to do this?

0 Likes
Highlighted
Pathfinder
93 6 14

Use this:

 

https://shop.example.com/cart/update?updates[Variant ID HERE]=1&redirect=/collection/all

 

Also you can only use 1 ? for URL Query.  Anythng past that, you use & symbols. 

1 Like
Highlighted
New Member
3 0 0

Thanks for that info on the URL Query! Good to know.

 

I tried your URL structure and it does add the item to the cart, but it still takes the user to the cart page and does not redirect back to the collections page.

 

https://shop.example.com/cart/update?updates[31430858440768]=1&redirect=/collections/all

Am I doing something wrong?

0 Likes
Pathfinder
93 6 14

The Code is right, but it looks like it needs to fully load the cart page to add it, and at that point its not running to redirect.  Looks like cart is final destination type page :/

 

Maybe another Dev might see a way but i been running some tests and i'm coming up short with the Query way of doing it.  Sorry mate.

0 Likes
Highlighted
New Member
3 0 0

Thanks for trying!

 

Anyone else have an idea how I can do this?

0 Likes
Highlighted
Pathfinder
93 6 14

@StartrekMcKlunk You could use an AJax cart instead.  This way its not directing to the cart page, but rather to a frame in the current pages code.  I have not tried it with an AJax cart, but it might get around this issue.

0 Likes