Skip to content

Instantly share code, notes, and snippets.

@keyurshah
Forked from zakhardage/product price table
Created April 11, 2017 14:17
Show Gist options
  • Save keyurshah/cdc6f4d68bb9597ca643354ebcc68a5f to your computer and use it in GitHub Desktop.
Save keyurshah/cdc6f4d68bb9597ca643354ebcc68a5f to your computer and use it in GitHub Desktop.
product price table - hard coded value categories
{% for variant in product.variants %}
{% assign option = variant.option1 | downcase %}
{% assign p = variant.price | money %}
{% unless option contains '+' or option contains 'swatch' %}
{% if option contains '1-4' %}
{% assign one = p %}
{% else %}
{% unless option contains '-' %}{% assign one = p %}{% endunless %}
{% endif %}
{% endunless %}
{% if option contains '5+' or option contains '5-9' %}{% assign two = p %}{% endif %}
{% if option contains '10+' or option contains '10-19' %}{% assign three = p %}{% endif %}
{% if option contains '20+' or option contains '20-49' %}{% assign four = p %}{% endif %}
{% if option contains '50+' %}{% assign five = p %}{% endif %}
{% endfor %}
<table>
<colgroup>
<col span="1" class="col1">
<col span="1" class="col2">
</colgroup>
{% assign unit_term = product.variants[0].option1 | split:' ' %}
<tr><th>Qty</th><th>Price per {{ unit_term.last }}</th></tr>
<tr>
<td>1&ndash;4</td>
<td>{{ one }}</td>
</tr>
<tr>
<td>5&ndash;9</td>
<td>{{ two }}</td>
</tr>
<tr>
<td>10&ndash;19</td>
<td>{{ three }}</td>
</tr>
<tr>
<td>20&ndash;49</td>
<td>{{ four }}</td>
</tr>
<tr>
<td>50+</td>
<td>{{ five }}</td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment