Sales Counter

AI-generated summary

A sales counter can be displayed on Dawn product and collection pages using a product integer metafield named custom.sold_count and Liquid to show its value. Shopify does not automatically provide a per-product sales total for the storefront, so the initial count must be seeded from Analytics’ Sales by product report; the bulk editor can speed up entering counts for many products.

After seeding, a Shopify Flow workflow can increment the metafield when an order is created, using each order line item’s quantity. A test order is recommended to verify that the workflow updates the count. The proposed setup does not automatically subtract refunds or cancellations, and orders containing multiple variants of the same product may cause undercounting with the basic loop; a custom code step or separate workflows may be needed for those cases.

For theme resilience, the display is better added through Custom liquid or an appropriate theme component than directly editing Dawn’s price.liquid. Apps are also an alternative. The approach is outlined, but no implementation results or follow-up test are reported.

I am using the Dawn theme.
Is there any way to configure/integrate a sales counter on our backend?
Want to shows on both collection and product page

Hi @kimtime

Shopify does not count sales per product for you. The number comes from the Sold count field you fill in.

Before

After

Steps

  1. Go to Settings, then Metafields and metaobjects.
  2. Click Products.

  1. Click Add definition.

  1. Type Sold count as the name. Choose Integer as the type. Click Save.

  1. Go to Products and open a product. Type its number of sales in Sold count. Click Save. Repeat for your other products.

  1. Go to Online Store > Themes. Click the three dots on your current theme. Click Edit code.

  1. Open Snippets > price.liquid. Scroll to the bottom. Click at the start of the last line, which is {% endunless %}. Paste this code above it:
{%- if product and product.metafields.custom.sold_count.value > 0 -%}
  <p style="margin:0.4rem 0 0;font-size:1.3rem;font-weight:600;color:#c2410c;">{{ product.metafields.custom.sold_count.value }} sold</p>
{%- endif -%}

  1. Click Save.

The counter shows on your product page and on every collection page.

Tested on a Dawn store.

Alternatively use apps

  • Sold Count: Low Stock Counter
  • Sold Count: Product Sale Proof
  • Stock Sheep - Sold & Low Stock

Regards,
Ploqo

Hi @kimtime,

Ploqo’s metafield + Liquid path is the right shape for Dawn. The gap is keeping that number in sync with real orders so it doesn’t go stale (Clovia’s trust point is fair).

Shopify won’t push a live “units sold” number into the storefront for you, but you can keep a product metafield updated automatically with Flow (free):

  1. Metafield (if you don’t have it yet): Settings → Custom data → Products → Add definition. Name Sold count, namespace/key custom.sold_count, type Integer. Save.
  2. Seed it once from Analytics → Reports → Sales by product (last whatever period you want the counter to start from), and type those totals into Sold count so you’re not starting at zero after years of sales.
  3. Flow: Apps → Flow → Create workflow
    • Trigger: Order created
    • Action: For each → Order → lineItems
    • Inside the loop: Update product metafield
      • Product: the line item’s product
      • Namespace: custom
      • Key: sold_count
      • Type: Integer
      • Value:
{{ lineItemsForeachitem.product.metafields.custom.sold_count.value | default: 0 | plus: lineItemsForeachitem.quantity }}
  1. Turn the workflow on. Place a test order and confirm Sold count ticks up.

Caveats worth knowing

  • If one order has two variants of the same product, Flow can overwrite itself in the loop and under-count. Rare for a lot of catalogs; if it matters for you, use a Run code step to sum quantity per product ID once, then update each product once.
  • Refunds/cancellations don’t reverse the counter unless you add a second workflow for those events.
  • Prefer a Custom liquid block in the product/collection templates over editing price.liquid, so a Dawn update doesn’t wipe the display. Same Liquid Ploqo posted works in a Custom liquid block on the product info section; for collection cards you’d add a small snippet or block that prints product.metafields.custom.sold_count.

That gives you a real, auto-updating counter on product and collection pages without an app. If anything in the Flow step errors on save, paste the error here and we can tighten the Liquid.

I need to add the sale count manually for all the products for the first time, correct? Then it will be automatically tracked?

@kimtime yes that’s right. The Flow only adds to the number when a new order comes in after you turn it on, it doesn’t go back and count old orders. So you set the starting number once and then it ticks up on its own.

You don’t have to open every product to do that though. Pull the sales by product report in Analytics for whatever period you want the counter to start from, then open the bulk editor on your products, add the Sold count column and paste the numbers in. Way faster if you have a lot of products.

Two things to keep in mind: refunds and cancellations won’t bring the number back down unless you build a second workflow for that, and it’s worth placing one test order after you switch it on to make sure the count actually changes on the product page.