Liquid, JavaScript, themes, sales channels
Hi all,
I'm trying to use the new product meta-field to add cross-sell products to my cart.
https://help.shopify.com/en/manual/metafields
How can I get the product into the liquid. I have added the below code:
{{ item.product.metafields.product.cross_sell_product_1 }}
It is returning string like this : gid://shopify/Product/xxxxxxxxxxxxxxx
https://shopify.dev/apps/metafields/definitions/types
How I can get the product from this with liquid, So I can show the product name, image, name and varients.
Thank you!
Solved! Go to the solution
This is an accepted solution.
You can use code:
{% assign productMetafields = all_products[item.product.metafields.product.cross_sell_product_1] %}
Then you can display it with variable productMetafields.
Hope it helps!
This is an accepted solution.
You can use code:
{% assign productMetafields = all_products[item.product.metafields.product.cross_sell_product_1] %}
Then you can display it with variable productMetafields.
Hope it helps!
It doesn't work for me. When I choose a product in the metafield as a related product, the value of the variable you are assigning here is blank.
[[object]].metafields.[[namespace]].[[key]]
this returns nothing.
In the latest for select multiple product reference, you can show like this :
{% for refer_product in item.product.metafields.product.multiple_reference.value %}
{% assign productName = refer_product.title %}
{% assign productHandle = refer_product.handle %}
{% endfor %}
for single meta title use like:
{% assign refer_product = item.product.metafields.product.single_reference.value %}
{% assign productName = refer_product.title %}
{% assign productHandle = refer_product.handle %}
More support, you can contact pedroinfosoft@gmail.com
how to add product reference metafield in theme? here i done some step after what to do i can not know help me to solve out.
check above code
{% assign cross_sell_product = item.product.metafields.product.cross_sell_product_1.value %}
Then you can use `cross_sell_product` as a product object in liquid.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024