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

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” %}({{ product.price | divided_by: product.metafields.Produkt.Volumen | times: 10 | money }}/l){% endif %}

Result in HTML:

(16,00€/l)

Now I want to use the new implementation:

{% if product.variants.first.unit_price_measurement %}({{ product.variants.first.unit_price_measurement.reference_value }}€/{{ product.variants.first.unit_price_measurement.reference_unit }}){%- endif -%}

Result in HTML:

(1€/l)

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 -%}({{ 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

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 hilfe@shopify.de). I’m pretty sure we’ll find the solution.

Thanks a lot in advance!

Best,

Ferry