skip to Main Content

In Shopify I need to control whether certain products are able to display add to cart.

In the past I have tagged the product as "hide cart" and switched theme template to a version without the button.

How could I do this using the Porto theme?

Does it have a built in method of doing this or do I need to manipulate the theme partials / templates?

2

Answers


  1. The simplest way that I can think of is to add a tag to all the products that you want to hide the add to cart button from, for example hide-add-to-cart.

    Then find the code that renders the button and wrap it in an unless statement:

    {% unless product.tags contains 'hide-add-to-cart' %}
      <button>Add to cart</button>
    {% endunless %}
    
    Login or Signup to reply.
  2. Does it have a built-in method of doing this or do I need to manipulate the theme partials/templates?

    No, there is no way to do it, rather than modify the existing code or add a new template and assign the template to a particular product like your previous theme.

    So basically there are 2 ways to achieve it:

    1. as @Karim Tarek said you need to tag those products and then check the particular tag into snippets where the Add to cart formed and disable it or hide it.

    2. you need to create a template where you simply copy the code from the default product template and comment the code is for Add to cart and choose this template for those products on which you don’t want to show the Add to cart button.

    Code samples:
    1.

    {% unless product.tags contains 'you tag to hide product' %}
      you HTML code that formed the Add to cart button
    {% endunless %}
    

    enter image description here
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search