Skip to content

Instantly share code, notes, and snippets.

@zakhardage
Created March 26, 2017 03:40
Show Gist options
  • Save zakhardage/bdbec2689539b37790ce893257f4af12 to your computer and use it in GitHub Desktop.
Save zakhardage/bdbec2689539b37790ce893257f4af12 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