Custom product property / Hide "Add To Cart" button

Solved
user73943
Tourist
4 1 0

I am using Shopify for the first time and this is my first post in the community (:

I am trying to add several products on my store but there are some that I don't sell online and I want to add a condition to show case a text for these products. I can't seem to figure out how I can add my own product property on the add product page that can be toggled on/off and depending if it has been toggled I want to set the "Add to Cart" to "display: none" and instead have a text block I have created in the theme to display.

Does anyone know how I could add custom product properties on the add product page? All feedback is greatly appreciated 

0 Likes
Guleria
Shopify Partner
1441 296 410

Hello,

You can simple create and use an alternate template for the products where you don't want to show add to cart button.
Here you can find how to create an alternate template https://shopify.dev/tutorials/customize-theme-create-alternate-templates

Thanks

Want to modify or custom changes on store hire me.
Email: guleriathakur43@gmail.com, Skype: navrocks1
If helpful then please Like and Accept Solution.
0 Likes
user73943
Tourist
4 1 0

This is an accepted solution.

You will need to go onto Template -> Product.liquid and find the <form></form> tags which the cart is in.

Then you need to put the following code before the opening <form> and {% form %} tags. The 'hide-cart-tag' can be replaced with whatever you would like to call the tag.

{% unless product.tags contains 'hide-cart-tag' %}

 You then need to place the following code after the closing </form> and {% endform %} tags.

{% endunless %}

 

This is an example of how your final code will look like, I've taken off most of the code that would usually be there to make it simple.

{% unless product.tags contains 'hide-cart-tag' %}
    {% form "product", product %}
        <form data-node-type="add-to-cart-form" class="commerceaddtocartform">
            <input type="submit" value="Add To Cart" data-node-type="add-to-cart-button" data-loading-text="Adding to cart..." class="commerceaddtocartbutton">
        </form>
    {% endform %}
{% endunless %}
0 Likes