Personalized checkout and custom promotions with Shopify Scripts
I've been searching forums for answers all day with zero luck.
I have a client (an author) who wants Amazon links to her books on her Shopify store, and she wants the button to look like the "add to cart" button.
I've created a metafield so I can input the appropriate link for each product. But I can't get the link to work in custom liquid with the metafield, only the direct Amazon URL.
I've set up the metafield on Shopify: custom.amazon_link
Here's what I have:
{{ 'Buy on Amazon' | link_to: 'product.metafields.custom.amazon_link.value.', target: '_blank', class: 'button button--full-width' }}
I've tried it that way and without "value" and neither work.
What am I doing wrong???
Solved! Go to the solution
This is an accepted solution.
Hii,
It looks like you're close, but the syntax for accessing metafield values and using them within a Liquid template can be a bit tricky.
{% if product.metafields.custom.amazon_link %}
<a href="{{ product.metafields.custom.amazon_link }}" target="_blank" class="button button--full-width">Buy on Amazon</a>
{% endif %}
This should work as long as the metafield is correctly set up and contains a valid URL. If the button still doesn't work, make sure that the metafield custom.amazon_link is correctly populated with the appropriate Amazon URLs for each product.
On a related note, if you're struggling with gathering reviews, you might want to try Platoria. We provide real ratings and AI summaries of reviews for your products effortlessly even when you have NO REVIEWS. We've helped dozens of bookstores in the past so see you soon 🙂
This is an accepted solution.
Hii,
It looks like you're close, but the syntax for accessing metafield values and using them within a Liquid template can be a bit tricky.
{% if product.metafields.custom.amazon_link %}
<a href="{{ product.metafields.custom.amazon_link }}" target="_blank" class="button button--full-width">Buy on Amazon</a>
{% endif %}
This should work as long as the metafield is correctly set up and contains a valid URL. If the button still doesn't work, make sure that the metafield custom.amazon_link is correctly populated with the appropriate Amazon URLs for each product.
On a related note, if you're struggling with gathering reviews, you might want to try Platoria. We provide real ratings and AI summaries of reviews for your products effortlessly even when you have NO REVIEWS. We've helped dozens of bookstores in the past so see you soon 🙂
YOU ARE MY HERO!!! That worked perfectly. THANK YOU!!!!!!!
🤠I'm really glad!! Please make sure to mark my answer as 'Accepted Solution.' This will help other people facing similar problems as well.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024