Shopify themes, liquid, logos, and UX
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi there!
I'm using the Prestige theme, and I have added some code to add a 'add to cart' button on the collections page. It works great, but now I need to hide it for products sold out or unavailable.
Unfortunately, the button keeps showing up, so I am manually hiding those products at the moment, which is not ideal.
I would appreciate your help so much!
Thanks!
Solved! Go to the solution
This is an accepted solution.
@GTStudio
Replace your code with below code.
{% if product.available %}
<button
class="ProductForm__AddToCart Button {% if product.selected_or_first_available_variant.available and use_primary_button %}Button--primary{% else %}Button--secondary{% endif %} Button--full"
onclick="_addMeToCart(event,this)"
data-action="open-drawer" data-drawer-id="sidebar-cart"
data-variant_id="{{ product.variants.first.id }}">
{{ 'product.form.add_to_cart' | t }}
</button>
{% endif %}
Hello @GTStudio,
Please share your website URL.
and also share you product-grid.liquid file code.
@MandasaTech The website URL is: https://sunshineliving.dk/
But I can't find the product-grid.liquid file code. Is there anything else I can provide you with?
https://sunshineliving.dk/password - please share your store password.
Hi @GTStudio,
You can hide the add to cart button by using a liquid condition, we need access to the code to provide a solution.
@SmallTask This is the code I pasted in product-item.liquid
<button
class="ProductForm__AddToCart Button {% if product.selected_or_first_available_variant.available and use_primary_button %}Button--primary{% else %}Button--secondary{% endif %} Button--full"
onclick="_addMeToCart(event,this)"
data-action="open-drawer" data-drawer-id="sidebar-cart"
data-variant_id="{{ product.variants.first.id }}">
{{ 'product.form.add_to_cart' | t }}
</button>
Thanks so much. Let me know if you need anything else.
@SmallTask @MandasaTech, any updates on this, please?
I would be so grateful if you could help! 🙏
This is an accepted solution.
@GTStudio
Replace your code with below code.
{% if product.available %}
<button
class="ProductForm__AddToCart Button {% if product.selected_or_first_available_variant.available and use_primary_button %}Button--primary{% else %}Button--secondary{% endif %} Button--full"
onclick="_addMeToCart(event,this)"
data-action="open-drawer" data-drawer-id="sidebar-cart"
data-variant_id="{{ product.variants.first.id }}">
{{ 'product.form.add_to_cart' | t }}
</button>
{% endif %}
Hi, I was hoping you could help us too.
I pasted this code on our prestige theme. It shows the button on the collection pages, but when I click the "add to cart button", it just open the cart drawer and not put the products in. Also, how can we add a choice for variants here? We have some products that have variants, is it possible for the customer to select the variants on the quick add?
Our URL is https://www.usandtheearth.com/collections/all
Hi @GTStudio, resolve the issue of missing "Add to Cart" buttons on Shopify collection pages by watching this helpful YouTube tutorial: https://www.youtube.com/watch?v=s98l1bUZe6k