Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi all. I'd like to see if I can hide a products 'Add to Cart' button if they have already bought a product.
On the store I am working on all customers have to log in first before they can see/buy products. Is there a way the theme can check their purchase history and replace the 'Add to Cart' button with a message?
Thanks in advance for any help. :^)
Hi @Nigel_Burke
use the below code to achieve the same.
{% if customer.orders_count > 1 %}
<h1>Order Count is greater than 1</h1>
{% endif %}
Hope it will help...
Thanks for getting back to me so quickly. Will this code work on individual product pages? I mean, it will check if the customer has purchased that particular product?
yes, it will everywhere at shopify
Thanks. I struggled to get it to work the way I needed it. However, I manage to get this to work for me. In this case the client will be happy with this...
{% for order in customer.orders %}
{% for line_item in order.line_items %}
{% if line_item.title contains product.title %}
<br>
<h4><i class="ad ad-exclamation-triangle" style="color:red;"></i> It looks like you may have already purchased this item.</h4>
<h6>Please check your <a href="/account" style="color:#25ECC0;"><b>Account Downloads <i class="ad ad-download-r"></i></b></a></h6><br>
{% endif %}
{% endfor %}
{% endfor %}
Hi Nigel, Any idea how to enable this text on collection pages as well, by replacing 'add to cart' to already bpught??
The logic will be the same to implement this it's just that you need to code it on card-product.liquid page.
Please refer to the below video to implement the same.
Hope this will help...
Your video is not related to the main question, I dont know whatt did you mean
Hi Natalie,
I haven't look at this for a while but, yeah, the same logic should work on the collection pages too as mentioned by Gr_trading.
You're likely to find a Snippet called something like 'product-card-grid.liquid'. This is where the add-to-cart buttons should be for the theme you are working on. The coding would need to reside in here.
Hope that helps.
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025