How to disable Wishlist button on selected products?

To exclude Wishlist button on specific products belonging to certain collection, please use the below construct at appropriate location in your theme

Individual Product page

{% unless product.collections contains 'collection-handle' %}

//code snippet of smart wishlist
<div id="smartwishlist" data-product="{{ product.id }}" data-variant="{{ product.variants.first.id }}"></div>

{% endunless %}

Collection/Category Page

{% unless collection.handle contains 'collection-handle' %}

//code snippet of smart wishlist
<span class="smartwishlist" data-product="{{ product.id }}" data-variant="{{ product.variants.first.id }}"></span>

{% endunless %}

If you want to exclude the button from products belonging to multiple collections, you can use and operator

{% unless product.collections contains 'collection-handle' and product.collections contains 'collection-handle2' %}

//Smart Wishlist Snippet for single product page

{% endunless %}
{% unless collection.handle contains 'collection-handle' and collection.handle contains 'collection-handle2' %}

//Smart Wishlist Snippet for Collection pages

{% endunless %}

Leave a Reply

Your email address will not be published. Required fields are marked *