FROM CACHE - de_header

Wrong Result in product.variants.first.unit_price_measurement.reference_value

4 0 1

Hello everyone,


any idea why unit_price_measurement is only available for variants ?


But I have another Problem.


Currently I'm calculating my liter price manually:

{% if product.variants.first.sku == "Flasche" %}<font size="1">({{ product.price | divided_by: product.metafields.Produkt.Volumen | times: 10 | money }}/l)</font>{% endif %}

Result in HTML:

<font size="1">(16,00€/l)</font>

Now I want to use the new implementation:

{% if product.variants.first.unit_price_measurement %}<font size="1">({{ product.variants.first.unit_price_measurement.reference_value }}€/{{ product.variants.first.unit_price_measurement.reference_unit }})</font>{%- endif -%}

Result in HTML:

<font size="1">(1€/l)</font>

The result should be 16,00 € / liter.

So he is doing something, but giving me the wrong number.

Also does  {% if product.variants.first.unit_price_measurement %} work, since I get a result shown at all.


Question: Why is shopify giving me the wrong value for {{ product.variants.first.unit_price_measurement.reference_value }} ? Any Idea?

On the normal product page it works ok:

{%- if variant.unit_price_measurement -%}<span class="price theme-money"><font size="2">({{ 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 -%}

But I cannot use that implementation in the collection.


Regards, Sven

Shopify Staff
Shopify Staff
20 0 15

Hi Sven,

thanks a lot for post. I definitely can ensure you that unit prices will be available for products without variations soon, too. Due to a dependency to another project it couldn't be released, yet. Regarding your implementation question: please feel free to contact our German support (e.g. via email I'm pretty sure we'll find the solution.


Thanks a lot in advance!