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

Metafields errors

Metafields errors

Lisa4689
Tourist
4 0 2

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:

  1. Created two custom metafields:

    • Is Amazon Product (True/False)

    • Affiliate Link (URL)

  2. 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.

Replies 10 (10)

PaulNewton
Shopify Partner
8031 687 1646

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


Guleria
Shopify Partner
4299 825 1189

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

- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.
Lisa4689
Tourist
4 0 2
Guleria
Shopify Partner
4299 825 1189

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 %}

- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.
Lisa4689
Tourist
4 0 2

Thank you. I still get this error. This product is not available on Amazon.

Guleria
Shopify Partner
4299 825 1189

Then maybe issue is something else.

Please drop an email for services. if you need me to check your theme files. 

 

Regards
Guleria

- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.

rajweb
Shopify Partner
845 71 161

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

Rajat | Shopify Expert Developer
Need a reliable developer for your next Shopify project? Let's connect!
Email: rajat.shopify@gmail.com
Portfolio: rajatweb.dev
Your one-stop partner for Shopify development, SEO, and performance. Let’s grow your store together!
Lisa4689
Tourist
4 0 2

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 %}

Dreww1
Tourist
4 1 1

Hey @Lisa4689 same here... I've also facing related metafield integration problem..

kingone198
Visitor
2 0 0

Polite greetings, here is the URL to test