Change Add to Cart text only for products with a certain tag

Solved
EmeraldService
Visitor
2 0 1

Hi all,

 

I need to modify the Add to Cart button text to show "Place Special Order" when an item has SpecialOrder:Y as a product tag. I see in the product-info.liquid file there is this line of code:

{%- else -%}
<button type="submit" class="product-form__add-button button button--primary" data-action="add-to-cart">{{ 'product.form.add_to_cart' | t }}</button>
{%- endif -%}

However, I can't find what to edit to change the Add to Cart button text or if this is even the correct line to edit.

 

I'm thinking I can add an if statement like so, so that only items with that tag get changed:

{%- if product.tags contains 'SpecialOrder:Y' -%}

I'm not sure of the best place to put it, and what exactly would go in it. Any help would be appreciated. Currently using the theme warehouse.

 

Accepted Solution (1)
JoesIdeas
Shopify Expert
2033 183 536

This is an accepted solution.

If that code above is for the add to cart button, then I would just copy that same format.

 

{% if product.tags contains "SpecialOrder" %}
  <button type="submit" class="product-form__add-button button button--primary" data-action="add-to-cart">Special text to show on ATC button</button>
{% else %}
  <button type="submit" class="product-form__add-button button button--primary" data-action="add-to-cart">{{ 'product.form.add_to_cart' | t }}</button>
{% end %}

 

 

To test this, duplicate your live theme then make the edits in the new theme.

 

Usually this would be found in a file like product-info.liquid, product-form.liquid, etc. If you can't find it, start with the product.liquid template and read the code to see each of the snippets that are added, then open those files and look for add to cart code.

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks

View solution in original post

Replies 3 (3)
JoesIdeas
Shopify Expert
2033 183 536

This is an accepted solution.

If that code above is for the add to cart button, then I would just copy that same format.

 

{% if product.tags contains "SpecialOrder" %}
  <button type="submit" class="product-form__add-button button button--primary" data-action="add-to-cart">Special text to show on ATC button</button>
{% else %}
  <button type="submit" class="product-form__add-button button button--primary" data-action="add-to-cart">{{ 'product.form.add_to_cart' | t }}</button>
{% end %}

 

 

To test this, duplicate your live theme then make the edits in the new theme.

 

Usually this would be found in a file like product-info.liquid, product-form.liquid, etc. If you can't find it, start with the product.liquid template and read the code to see each of the snippets that are added, then open those files and look for add to cart code.

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks
EmeraldService
Visitor
2 0 1

Worked perfectly, I just added an else if statement with this line and all is good. 

{% elsif product.tags contains 'SpecialOrder:Y' %}
   <button type="submit" class="product-form__add-button button button--primary" data-action="add-to-cart">Place Special Order</button>

 Thank you for the assistance!

JoesIdeas
Shopify Expert
2033 183 536

Woohooo!

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks