#Add order to cart
If you've got awesome Shopify customers that return each month to buy the same thing you don't want to force them to have to re-add everything to cart each time. With some theme edits it's possible to add a feature that does just this - let's explore some very example Liquid and JavaScript code.
Relates to the blog post How to create a button to let customers repeat their previous order
To use, create a snippet called 'order-to-cart.liquid' and paste the content of the gist in. In order.liquid just add {% include 'order-to-cart' %}
wherever you like.
Now if you just want to use permalinks instead you could use this bit of magic instead:
<a href="/cart/{% for line_item in order.line_items %}{{ line_item.variant_id }}:{{ line_item.quantity }}{% unless forloop.last %},{% endunless %}{% endfor %}">Reorder this</a>
Hi there,
Great snippet! Works well for me, with one issue. Each of my products may or may not display custom line item properties.
The script seems to call them on line 18:
properties: {{ line_item.properties | json }}
But they don't display when added back into the cart. Do I need to modify my
cart.liquid
? I am calling them in my cart like so:I'm not the best at liquid and am newer to Shopify, so any help you could provide would be greatly appreciated.
Thanks so much!
Mark