Liquid, JavaScript, themes, sales channels
Hi there,
I'm trying to display unit prices for our products. (We don't have that option to do that in our store because we are based in the US.)
The color variants come in packs of 12 or 18 units.
For example: A user wants the pink in a case size that contains 18. The option is called Size and the name is B18.
Below is as far as I got in the code, if someone could please let me know what I'm doing wrong it would be amazing! I'm only able to get all products to divide by 12.
{% assign twelve = false %}
{% assign eighteen = false %}
{% assign unit = '12' %}
{% for value in option.values %}
{% if selected_value == 'B18' %}
{% assign eighteen = true %}
{% assign unit = '18' %}
{% endif %}
{% endfor %}
.......
<div class="product-price product-price--large" data-price-wrapper>
<span class="{% if current_variant.compare_at_price > current_variant.price %}product-price__reduced{% endif %}" data-product-price>
<span class="theme-money">{{ current_variant.price | divided_by: unit| money }}</span>
</span>
{% if product.compare_at_price_max > product.price %}
<span class="visually-hidden" data-compare-text>{{ 'products.product.regular_price' | t }}</span>
<span class="product-price__compare {% unless current_variant.compare_at_price > current_variant.price %}hide{% endunless %}" data-compare-price>
{% if current_variant.compare_at_price > current_variant.price %}
<span class="theme-money">{{ current_variant.compare_at_price | divided_by: unit | money }}</span>
{% endif %}
</span>
{% endif %}
{% render 'unit-price', variant: current_variant %} Per Pair
<span style="font-size:14px;"><br> MSRP: {{ product.metafields.msrp.msrp }}</span>
</div>
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024