How can I call a variant metafield for unit pricing on my website?

How can I call a variant metafield for unit pricing on my website?

Haris_Ahmed
Shopify Partner
9 0 1

Hello Everyone

 

I have a website called https://allseasonamericanflooring.com if you check the products. I have added per unit pricing in both collections and product pages. Here is the code for it

<div class="grid-product__price">
{%- if on_sale -%}
<span class="visually-hidden">{{ 'products.general.regular_price' | t }}</span>
<span class="grid-product__price--original">{{ product.compare_at_price | divided_by:pcs_per_box | money }}/{{ price_uom }}</span>
<span class="visually-hidden">{{ 'products.general.sale_price' | t }}</span>
{%- endif -%}
{%- if product.price_varies -%}
{%- assign price = product.price_min | money -%}
<span {% if on_sale %}class="sale-price"{% endif %}>
{{ 'products.general.from_text_html' | t: price: price }}
</span>
{%- else -%}
<span {% if on_sale %}class="sale-price"{% endif %}>
{{ current_variant.price | divided_by:pcs_per_box | money }}/{{ price_uom }}
</span>
{%- endif -%}

{%- assign product_variant = product.selected_or_first_available_variant -%}
{%- if product_variant.unit_price_measurement -%}
<div class="product__unit-price">
{%- capture unit_price_base_unit -%}
{%- if product_variant.unit_price_measurement -%}
{%- if product_variant.unit_price_measurement.reference_value != 1 -%}
{{ product_variant.unit_price_measurement.reference_value }}
{%- endif -%}
{{ product_variant.unit_price_measurement.reference_unit }}
{%- endif -%}
{%- endcapture -%}

{{ product_variant.unit_price | divided_by:pcs_per_box | money }}/{{ unit_price_base_unit }}{{ price_uom }}
</div>
{%- endif -%}

I would like to change this divided by pcs into a metafield where we are already adding the per unit price. I want this called using that variant metafield which I have created. I tried doing it but I am 

Replies 0 (0)