abbrechen
Suchergebnisse werden angezeigt für 
Stattdessen suchen nach 
Meintest du: 

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

Tourist
3 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 }})
</font></span>
{%- endif -%}

But I cannot use that implementation in the collection.

 

Regards, Sven

0 Likes
Highlighted
Shopify Staff
Shopify Staff
2 0 0

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

0 Likes