Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello, looking for advice!
I have a few digital products that are not for sale in my store - they're displayed with the other goods, but when you open the product page, you can click the link to buy it somewhere else. The problem is they have quick add buttons on mainpage, or on collection page. I need to hide quick add buttons for digital products.
I tried using the following code in card-product.liquid:
{% unless product.collections contains 'digital' %}
...(all the quick add code)...
{% endunless %}
=== no result 😞
I tried also using tags and {% unless product.tags contains 'digital' %} -- no result.
I tried changing names and {% unless product.title contains 'digital' %} -- no result.
I thought "maybe I'm placing the code in wrong place?" - and, for experiment, changed UNLESS to IF. All of the quick add buttons for all products were hidden (including the digital products). So I guess the place is correct, but I'm doing something wrong.
Any advice much appreciated! Theme Dawn 2.0
Solved! Go to the solution
This is an accepted solution.
I did! It's for Dawn theme.
First, add a specific tag to the products where you need to hide quick add buttons (in my case, the tag is 'digital')
Then, you need to amend the file 'main-collection-product-grid.liquid'. Find the code for a product card:
<li class="grid__item">
{% render 'card-product',
card_product: product,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load,
show_quick_add: section.settings.enable_quick_add,
section_id: section.id
%}
</li>
The string which display quick add button is (surprise!) show_quick_add. Thus, we need to create two instances for this part of cose - one with this line, one without it. Here we go: we replace the code above with the following:
{%- unless product.tags contains "digital" -%}
<li class="grid__item">
{% render 'card-product',
card_product: product,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load,
show_quick_add: section.settings.enable_quick_add,
section_id: section.id
%}
</li>
{%- endunless -%}
{%- if product.tags contains "digital" -%}
<li class="grid__item">
{% render 'card-product',
card_product: product,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load,
section_id: section.id
%}
</li>
{%- endif -%}
This code hides quick add buttons for products tagged 'digital' in product grids (both on a collection page and on a frontpage in 'featured collection').
I have the same problem. Any update on this? Were you able to solve it? Thank you!
This is an accepted solution.
I did! It's for Dawn theme.
First, add a specific tag to the products where you need to hide quick add buttons (in my case, the tag is 'digital')
Then, you need to amend the file 'main-collection-product-grid.liquid'. Find the code for a product card:
<li class="grid__item">
{% render 'card-product',
card_product: product,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load,
show_quick_add: section.settings.enable_quick_add,
section_id: section.id
%}
</li>
The string which display quick add button is (surprise!) show_quick_add. Thus, we need to create two instances for this part of cose - one with this line, one without it. Here we go: we replace the code above with the following:
{%- unless product.tags contains "digital" -%}
<li class="grid__item">
{% render 'card-product',
card_product: product,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load,
show_quick_add: section.settings.enable_quick_add,
section_id: section.id
%}
</li>
{%- endunless -%}
{%- if product.tags contains "digital" -%}
<li class="grid__item">
{% render 'card-product',
card_product: product,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load,
section_id: section.id
%}
</li>
{%- endif -%}
This code hides quick add buttons for products tagged 'digital' in product grids (both on a collection page and on a frontpage in 'featured collection').
Thank you so much for this! 😀👏
Hi, I'm trying to affect a similar change on my site (Venue Theme)
But my product card code is a little different:
{% render 'product-card',
current_product: product,
section_id: section.id,
collection: collection,
image_sizes: sizes,
small_buttons_on_mobile: small_buttons_on_mobile,
quick_shop_type: 'remote'
%}
I was wondering if I could affect the same change by tweaking the quick-shop-type: 'remote' line. But I'm unsure.
Many Thanks
Rik
Hi, I am SO glad to have found this! I also have some products to exclude from the Quick Add Button feature.
Would this work on a different theme? My store uses Craft Theme and code differs very slightly.
Not used to coding - is there an option to 'undo' changes?
Grateful for helpful persons 🙂
Diane 🙂
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024