Liquid, JavaScript, themes, sales channels
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.
Solved! Go to the solution
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.
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.
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!
Woohooo!
User | RANK |
---|---|
37 | |
27 | |
14 | |
13 | |
9 |
Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023