Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
621 views
in Technique[技术] by (71.8m points)

e commerce - Using Porto theme 3.6.3 in Shopify how can I turn off add to cart on specific products?

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?

question from:https://stackoverflow.com/questions/65864932/using-porto-theme-3-6-3-in-shopify-how-can-i-turn-off-add-to-cart-on-specific-pr

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 %}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...