Last active
March 8, 2021 13:08
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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