Let’s say on the the account page in Shopify, you want to add a reorder button that when clicked automatically adds all items for a previous order to the cart.
One strategy is to use a cart permalink, in the following format:
So by adding an item’s variant_id and quantity to the end of the URL, you can create a button or link that will populate the cart with that item. And you can append as many items as you want separated by commas.
So the question is, how to automatically construct that URL for each previous order? It’s done like so…
There is a redundant comma added onto the end of the URL, but Shopify ignores it when processing the URL’s parameters. So to keep things simple, I didn’t write the rather lengthy Liquid code to remove that last character.
Hope that helps someone!