How to add product meta fields to quick view modal dynamically?

How to add product meta fields to quick view modal dynamically?

Super_Star
Shopify Partner
3 0 2

Hi Everyone,

I am having an issue when I try to dynamically add product meta fields to the product Quick view modal.

 

So here is the detailed issue:

 

 

{%- assign product_handle = '[[ product.handle ]]' -%}

{{product_handle}}

{% assign how_to_use = all_products[product_handle].metafields.my_fields.how_to_use %}

{{how_to_use}}

 

 

In this case, {{product_handle}} returns the correct value: 'oilwater-replenish-nourish-rosehip-mini' but {{how_to_use}} returns an empty value.

 

Please help me with this problem.

Thank you

Reply 1 (1)

PaulNewton
Shopify Partner
7721 678 1625

Shopify functions are not for liquid issues https://community.shopify.com/c/shopify-functions/not-a-general-shopify-functionality-board/td-p/172... 

 

Use the value property on metafield definitions.

And this code had extra characters in it: [[ & ]]

{%- assign product_handle = '[[ product.handle ]]' -%}

Beyond that you need to confirm spelling of metafields key and namespace.

Then just make output at each level of what is being assigned to validate code.

i.e.

 

{% assign product = all_products[product_handle] %}
{{ product | json  }}
{{ product.metafields.my_fields.how_to_use | json }}
{{ product.metafields.my_fields.how_to_use.value }}

 

 

 

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org