I am experiencing an issue with the metafield integration on my product pages for Amazon affiliate links. I have set up the metafields for my products correctly, including an “Is Amazon Product” metafield (set to true) and an “Affiliate Link” metafield that contains the Amazon affiliate URL. However, despite this setup, the affiliate link is not displaying properly on the product pages.
Here are the steps I’ve taken so far:
Created two custom metafields:
Is Amazon Product (True/False)
Affiliate Link (URL)
Added values to these metafields for the relevant products (e.g., “Is Amazon Product” is set to true and “Affiliate Link” contains a valid Amazon URL).
However, the output shows that the affiliate link is either not recognized or not displayed properly, and the fallback message (“This product is not available on Amazon”) appears instead of the link. Despite everything being set up as per instructions, the link does not show as expected on the product page.
Can you please help me troubleshoot and resolve this issue? I would appreciate any guidance or steps to ensure the affiliate link is displayed correctly.
Hi @Lisa4689 just adding metafields doesn’t make them automagically appear inside a theme so there must be an omission of critical detail, i.e. “per instructions” doesn’t mean anything to other people you have to communicate what other people need to know.
There must either be a dynamic sources, a liquid setting/block/section, or some custom code involved.
If you need this fixed then contact me for services.
Contact info in forum signature below .
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.
Sure! It looks like the issue is with how the metafields are being called in your product template. Please check that the code is correctly referencing the metafields like this:
{% if product.metafields.custom.is_amazon_product == true and product.metafields.custom.affiliate_link != blank %}
Buy on Amazon
{% else %}
This product is not available on Amazon.
{% endif %}
Make sure:
Your namespace is correct (custom in this example).
The is_amazon_product metafield is of boolean type, not string.
You’ve published the metafields in your Shopify theme.
Let me know if you’d like help checking the theme code directly!