Skip to content

Instantly share code, notes, and snippets.

@ADTC
Forked from magician11/reorder-button.html
Last active September 29, 2023 15:04
Show Gist options
  • Save ADTC/63158892fb0dbf02180d2edd0baa9ca9 to your computer and use it in GitHub Desktop.
Save ADTC/63158892fb0dbf02180d2edd0baa9ca9 to your computer and use it in GitHub Desktop.
How to create a reorder button in Shopify's Liquid
{% for order in customer.orders %}
...
{% liquid
assign reorder_url = ''
for line_item in order.line_items
assign reorder_url = reorder_url | append: line_item.variant_id | append: ':' | append: line_item.quantity | append: ','
endfor
-%}
<a href="/cart/{{ reorder_url }}" class="btn btn--filled">{{ 'customer.orders.reorder' | t }}</a>
...
{% endfor %}
@rm014
Copy link

rm014 commented Feb 1, 2023

Hi, tried to use this in the customer's order liquid but i'm getting an error

@ADTC
Copy link
Author

ADTC commented Feb 2, 2023

@rose-abc I've replied you in the parent gist.

General warning: Don't copy-paste code from the internet without understanding what it does. In some cases, you could do irreversible damage.

@rm014
Copy link

rm014 commented Feb 2, 2023

yeah, fixed this yesterday. thanks @ADTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment