Shopify themes, liquid, logos, and UX
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi
We are a wholesaler, and the prices displayed are the pack prices.
I would like to show the unit prices below the original price, but only on the collection page.
I was able to add a custom liquid to the product page, and it worked, but the collection page doesn't allow me to add custom liquid directly.
The following code is the one that I put to the product page custom liquid.
{% comment %}
Custom code for displaying price based on size and calculating unit price.
{% endcomment %}
{%- assign variant = current_variant | default: product.variants.first %}
{%- assign price = variant.price | default: 1999 %}
{%- assign size_value = variant.options[1] %} <!-- Assuming the second option is size (index 1) -->
{%- assign total_units = 0 %}
{%- if size_value == "S-M-L-XL(2-2-2-2)" -%}
{%- assign total_units = 8 -%}
{%- elsif size_value == "S-M-L(2-2-2)" -%}
{%- assign total_units = 6 -%}
{%- elsif size_value == "1X-2X-3X(3-2-1)" -%}
{%- assign total_units = 6 -%}
{%- elsif size_value == "XS-S-M-L(1-2-2-2)" -%}
{%- assign total_units = 7 -%}
{%- elsif size_value == "XS-S-M-L-XL(1-2-2-2-1)" -%}
{%- assign total_units = 8 -%}
{%- elsif size_value == "S-M-L-XL(1-2-2-1)" -%}
{%- assign total_units = 6 -%}
{%- elsif size_value == "ONE SIZE(6)" -%}
{%- assign total_units = 6 -%}
{%- elsif size_value == "S/M-M/L(3-3)" -%}
{%- assign total_units = 6 -%}
{%- elsif size_value == "XS-S-M-L(1-2-2-1)" -%}
{%- assign total_units = 6 -%}
{%- elsif size_value == "S/M-M/L-L/XL(2-2-2)" -%}
{%- assign total_units = 6 -%}
{%- endif %}
<div class="custom-price-section">
<div class="price__default">
<!-- "Unit Price" and price in the same row -->
<span class="price__label">Unit Price:</span>
<span class="price__current">
{%- if total_units > 0 -%}
{%- assign unit_price = price | divided_by: total_units -%}
{%- if show_currency_code -%}
{{ unit_price | money_with_currency }}
{%- else -%}
{{ unit_price | money }}
{%- endif -%}
{%- else -%}
{%- if show_currency_code -%}
{{ price | money_with_currency }}
{%- else -%}
{{ price | money }}
{%- endif -%}
{%- endif -%}
</span>
</div>
</div>
Product Page:
Solved! Go to the solution
This is an accepted solution.
@JunNa just sent you details
Hi@JunNa ,
This code needs to be alter according to the collection card so that it display units price over there. Do let me know if you need further help.
Thanks
Hi, thank you!
How can I display the unit prices on the collection page the same way as on the product page?
Yes almost you have to find the correct file. Do you uave knowledge of code?
I am not an expert but I know how to edit code.
Ok then in the loop products card paste above code and test it. The file might be in the snippet folder with name product card liquid
Hi Thank you
But there is Product card liquid in the snippet folder with my Symmetry theme.
Is there any other way?
Thank you
I have to look into it. Is it possible?
Thanks
Sure.
What kind of information do you need?
Thank you
This is an accepted solution.
@JunNa just sent you details
Hi @JunNa!
Instead of hunting through theme files and modifying Liquid code, you might want to consider using an app as a simpler alternative.
Our app Weario handles exactly this scenario without needing to modify theme files. While it's primarily designed for fashion brands showing "per wear" pricing, the labels are fully customizable so you can display a "per unit" price for your wholesale packs.
For your complex pack configurations:
The advantage is you avoid the complexity of:
Since you already have the unit calculations working on product pages, this would give you the same functionality on collection pages with much less technical complexity.
https://apps.shopify.com/weario
Perfect for wholesale scenarios where customers need to understand per-unit value while browsing collections!