Change button text on one specific product page

Hi, I’m trying to update a specific landing page on my website and change the text on the add to cart button to say “Claim My Sample” but I can’t figure out where to change it. Help! HISTAsolv | Eat-All USA

1 Like

Hi @jasminsharp97

To change the button text, you’ll need to edit your theme code, dear.
Go to Online Store → Themes → Edit code, then open either main-product.liquid or product-form.liquid.

Look for a line like this:

{{ form | submit_button: 'Add to cart', class: 'product-form__submit' }}

Replace ‘Add to cart’ with ‘Claim My Sample’.
If you’d like, I can help you find the exact line — just let me know which theme you’re using.

My concern is if I update the main product liquid that it’ll change the button text on all the products, and I don’t want that. This is the only page where I want different button text. Will I be able to do that in one of those liquid files?

1 Like

Hi @jasminsharp97

Steps:
Go to Online Store → Themes → Edit Code

Open the file where the Add to Cart button text is located, usually:

main-product.liquid

or product-form.liquid

Find the code that prints the button text, for example:

{{ ‘products.product.add_to_cart’ | t }}
Replace that with this conditional code:

{% if product.handle == ‘your-product-handle’ %}
Your Custom Button Text
{% else %}
{{ ‘products.product.add_to_cart’ | t }}
{% endif %}

1 Like

Add this code in snippets > buy-buttons.liquid

  {% elsif page.handle == 'histasolv-facebook-sample' %}
   Claim My Sample

before the line number 90 before
{%- else -%}
{{ ‘products.product.add_to_cart’ | t }}
as screenshot, this will not change the default “Add to cart” text on other pages

That worked, thank you so much!!!

1 Like

Hi @jasminsharp97

Thank you for your response. It’s good to know that it’s worked for you. Kindly feel free to get back to me if you need any further assistance. If helpful, please like all posts. :white_check_mark: