Show badge "Already bought" to customer who have bought a product already

Hello Guys,

I want to display a badge “Already bought” on products to logged in customers who have already bought that product, the badge should be visibile on all pages such as collections, slidebar, gallery etc, Your help will be greatly appreciated.

Hi @NatalieG1 ,

Please refer to the below video to see how we can check the order history of the user you can iterate the order list and match the product ID to the current page.

Let me know if you still face any difficulties.

@NatalieG1

If requirement is to show “Already bought” badge on collection and product pages to remind customer of their previous purchase, then Buy Again & Reorder Reminders can help you achieve this. Have a look at the below image.

Hi @NatalieG1 .
Shopify does not support this natively since it needs to check a logged in customer’s order history against every product shown, even on collection and gallery pages. Your best options are an app with “purchased before” badges or custom code that tags past purchases to the customer profile and compares them to products via JS. Either way, it needs a custom setup. This is not something a simple Liquid snippet can do on its own.

@NatalieG1 you can show “already bought” using custom code in theme as Shopify provide order object in liquid for login users.

plz refer the image below for reference.

use below code to enable feature at your theme, however my recommendation will be don’t directly modify the theme if you are not well verse in coding.

{%- liquid
  assign latest_order_date = blank

  if customer and product
    for order in customer.orders
      if latest_order_date != blank
        break
      endif

      for line_item in order.line_items
        assign line_item_product_id = line_item.product_id | default: line_item.product.id

        if line_item_product_id == product.id
          assign latest_order_date = order.created_at
          break
        endif
      endfor
    endfor
  endif
-%}

{%- if latest_order_date != blank -%}
  <div class="customer-purchase-status customer-purchase-status--{{ context | default: 'default' }}">
    <span class="customer-purchase-status__icon" aria-hidden="true">
      {{- 'icon-checkmark.svg' | inline_asset_content -}}
    </span>
    <span class="customer-purchase-status__text">
      Last bought on {{ latest_order_date | date: '%b %d' }}.
    </span>
  </div>
{%- endif -%}

let me know if you need help implementing the same.