All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
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.
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
Hello @Lisa4689 ,
Can you confirm what's the output of it at the moment ?
And can you share any product URL where you set 'Is Amazon Product' -> True
Also confirm what you did for output. I mean use liquid block, dynamic source or directly call the metafield in code?
Regards
Guleria
Thank you, the output is nothing. Nothing happens.
Use this one
{% assign amazon_link = product.metafields.custom.affiliate_link %}
{% if product.metafields.custom.is_amazon and amazon_link != blank %}
<p><a href="{{ amazon_link }}" class="metafield-url" target="_blank">Buy this on Amazon</a></p>
{% else %}
<p>This product is not available on Amazon.</p>
{% endif %}
Thank you. I still get this error. This product is not available on Amazon.
Then maybe issue is something else.
Please drop an email for services. if you need me to check your theme files.
Regards
Guleria
Hey @Lisa4689 ,
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 %}
<a href="{{ product.metafields.custom.affiliate_link }}" target="_blank">Buy on Amazon</a>
{% else %}
<p>This product is not available on Amazon.</p>
{% 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!
Best Regards,
Rajat
This is what I have.
{% if product.metafields.custom.is_amazon == 'true' and product.metafields.custom.affiliate_link != blank %}
<p><a href="{{ product.metafields.custom.affiliate_link }}" class="metafield-url" target="_blank">Buy this on Amazon</a></p>
{% else %}
<p>This product is not available on Amazon.</p>
{% endif %}
Hey @Lisa4689 same here... I've also facing related metafield integration problem..