Price per unit: Link price to variants

New Member
3 0 0

Hey everyone!

Some background information:

I have a shop in Germany and here it's obligatory to show the price per unit. Recently, Shopify did include this function in the backend and provided some snippets which have to be placed in the themes' code in order to be displayed:


If you copy and paste them into the code nothing happens. With a little addition (for loop)  found on the board the code looks like this:


            {% for variant in product.variants %}
            {%- if variant.unit_price_measurement -%}
   ({{ variant.unit_price | money }}
  {%- if variant.unit_price_measurement.reference_value != 1 -%}
    {{- variant.unit_price_measurement.reference_value -}}
  {%- endif -%}
  {{ variant.unit_price_measurement.reference_unit }})
{%- endif -%}
{% endfor %}
And on the product page:
Bildschirmfoto 2019-10-13 um 19.29.55.png
Looks good! 
The problem now is the following: If I have two or more variants, the price per unit is displayed for all variants:
Bildschirmfoto 2019-10-13 um 19.32.17.png
My goal: I want to link the price per unit which is displayed in brackets to the variants. When somebody clicks on 300ml it has to show the first price/unit and if someone clicks on 460ml it has to show the second price/unit. It should change just like the product price itself.
Just like in this example:
Does anyone have an idea how to code this? I appreciate every suggestion!
Shopify Expert
1381 111 205

please share a store url

38 0 0

Hi dear, let's check this app for setting the flexible prices on all store products. Shopify price per unit app supports 100 types of measurement units.  It supports the variable-sized of products such as length, weight, area, volume. You can sell all kinds of variable-sized products based on their dimensions such as tiles, blinds, liquids, fabric, fencing, frames, wires, liquids, ropes, and many more.