Skip to content

Instantly share code, notes, and snippets.

@hsiehjack
Last active March 8, 2021 13:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsiehjack/939f5bb69d7be73ce50f7ceaade7b09a to your computer and use it in GitHub Desktop.
Save hsiehjack/939f5bb69d7be73ce50f7ceaade7b09a to your computer and use it in GitHub Desktop.
Shopify - Getting minimum and maximum price for variants in product. Found out product already has attribute for min and max. This can be used for custom function.
{% comment %}
{% assign price_min = 0 %}
{% assign price_max = 0 %}
{% for variant in product.variants %}
{% if price_min == 0 or price_max == 0 %}
{% assign price_min = variant.price %}
{% assign price_max = variant.price %}
{% endif %}
{% if price_min > variant.price %}
{% assign price_min = variant.price %}
{% elsif price_max < variant.price %}
{% assign price_max = variant.price %}
{% endif %}
{% endfor %}
{% endcomment %}
<strong>{{ product.price_max | money }} - {{ product.price_min | money }}</strong>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment