I want to create a custom amazon buy button for my product page so that if a product is out of stock on my website, he can buy the same product on amazon. So I need to link the button to the amazon product page. How can I achieve this using custom coding? I don’t want to rely on third-party apps, and just in case it is not feasible a good app recommendation is also appreciated.
{% if product.available %}
put your regular add to cart button code here
{% else %}
Buy on Amazon
{% endif %}
Your add to cart button code is probably in a section / snippet called product.liquid, or product-form.liquid, something like that. You can find that in your theme editor.
To style the button, you’ll use CSS, making some properties for how you want the button to look.
If you want to do on your own, I would do this:
Duplicate your live theme, then open the theme editor on the new theme
Read through the product.liquid template / section files to see where the add to cart button code is.
Add that snippet above and preview the theme. Once you see it you’ll know your code is working
Now style it by creating a custom.css file, including that in your theme.liquid file, and adding the CSS class there. If you’re not familiar with CSS, just google what you’re looking to do (for example: “how to make a button in CSS”).
If you prefer to have a developer handle it, I would either contact the team from that article, or browse experts.shopify.com. Something like this is a small job for a developer so won’t be too expensive.
{{ option.name }}:
{% for value in option.values %}
{{ value | escape }}
{% endfor %}
{% endcomment %}
{{ option.selected_value }}
{% for value in option.values %}
{{ value | escape }}
{% endfor %}
{% comment %}
Pack of 2
Pack of 3
{% endcomment %}
{% endfor %}
{% endunless %}
{% unless current_variant.available %}
{{ 'products.product.sold_out' | t }}
{% else %}
{{ 'products.product.add_to_cart' | t }}
{% endunless %}
{% include 'icon-spinner' %}
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}
{% endif %}
{% endform %}
{%- comment -%}
Live region for announcing updated price and availability to screen readers
{%- endcomment -%}
{%- comment -%}
Live region for announcing that the product form has been submitted and the
product is in the process being added to the cart
{%- endcomment -%}
My recommendation would be to use the Libautech: Amazon Buy Button app, as it includes an algorithm designed to improve your organic Amazon keyword ranking.