Re: Already Purchased Alert

How can I add a 'previously purchased' alert to my product pages?

LGRAM60
Excursionist
15 0 11

I am looking to add an alert on the product page that says the customer already purchased this item. Ideally it would also show on the items on the collection pages as most of my customers add to cart from those pages.  It can be text, or an icon/banner.  I have looked through the discussions but cannot find a solution. Is this possible? Any help would be appreciated. My site is americantraditioncookiecutters.com

Replies 5 (5)

Jason
Shopify Partner
11207 226 2318

Do you force your customers to log into their account? For something like this to work with theme code, you'd need to. Now forcing a log in can create friction in the purchase flow and effect conversions so that's something you first need to consider before starting down the path.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
LGRAM60
Excursionist
15 0 11

I appreciate your response. I do realize that it will only work with those who log in to their account. I do not wish to force people to log in to purchase, but was hoping to offer it to those who do log in. I guess it may be too difficult to implement at the current time. Maybe sometime down the road.

Jason
Shopify Partner
11207 226 2318

So if this is really just for those that do log in then there's some points to consider. 

Once logged in the theme will have access to the Customer object:
https://shopify.dev/docs/themes/liquid/reference/objects/customer

In that object is a customer.orders. This contains an array of the recent Orders the customer has placed.
https://shopify.dev/docs/themes/liquid/reference/objects/order

We're not into the code yet just in case you want to give it a crack first but for a general flow:

  1. create a variable with the variant IDs of the current product
  2. loop over the customers orders and look at the variant id for the line items.
  3. if there's a match, stop looping and shop a friendly "hey, you have bought this already" message.

 

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
RebeccaRoss
Tourist
3 0 2

This is what I need. Do you know how to add this to my store?

Wtfabric
Tourist
3 0 0

I am looking for exactly the option can you type out the exact code and where to put it?