SafeSale · Blog

A Shopify Sale collection that fills and empties itself

One collection condition, Compare-at price is not empty, builds a Sale page with no tagging. When it works, when it stays empty, and what sits in it forever.

Most stores have a Sale link in the menu. Behind it there is usually a collection that somebody fills by hand: tag forty products with "sale" on Thursday night, remember to untag them a week later, forget three. In January the page still shows a scarf that went back to full price in November.

Shopify can keep that page up to date without tags, using one condition on an automated collection. It only works if your sale changes the right field, though, and that depends on how the sale is built. SafeSale can run a sale two ways, and one of them fills this collection while the other leaves it empty. This post walks through the collection, both modes, and the products that end up in it when they should not.

The one condition

In the admin, go to Products, then Collections, and create a collection of the automated type (Shopify also calls it a smart collection). Add a single condition: Compare-at price is not empty. Save it and link it from your menu. Shopify's own examples page for smart collections uses exactly this recipe for a sale collection.

From then on Shopify decides membership. A product with something in the compare-at field is in. Clear the field and it is out. You cannot add or remove products by hand in an automated collection, which is the point: there is nothing to forget.

The same page carries a note that matters later:

  • If a product or any of its variants has a value in compare-at, the product counts as not empty.
  • That includes a value of 0. Zero is a value. Only a blank field is empty.

Rewrite mode: the collection fills when the sale starts

In price-rewrite mode SafeSale writes two fields on each variant in the sale. The price becomes the sale price, and compare-at becomes the price the variant had before, so the theme can strike it through. That second write is what the collection is watching for.

So the sequence for a product that had no compare-at price is simple. The sale starts, compare-at is filled, the product appears on the Sale page. The sale ends, SafeSale restores both fields from the snapshot it took before writing, compare-at goes back to blank, the product leaves the page. Nobody tags anything. A scheduled sale that starts at midnight has a full Sale page a little after midnight.

"A little after" is deliberate. A large sale is written in batches, and Shopify re-evaluates automated collections as products change, so the page fills over the minutes the sale takes to apply rather than all at once. Our post on how long a sale takes to apply has the numbers for the writing part.

Functions mode and automatic discounts: the collection stays empty

The other way to run a sale is a discount that Shopify applies in the cart and at checkout. SafeSale's Functions mode does that, and so does an automatic discount you create yourself in the admin. Neither writes to the product. Price and compare-at stay exactly as they were.

A collection that looks for compare-at prices therefore finds nothing new. If you launch 25% off the whole store as an automatic discount and send people to the Sale page, they see whatever was in it last month, or an empty grid. This is the most common reason for the "my sale collection is empty" question, and no setting fixes it, because the discount lives in checkout and the collection reads the catalog.

How the sale is runCompare-at during the saleAutomated Sale collection
SafeSale, price rewriteSet to the pre-sale priceFills at the start, empties at the end
SafeSale, Functions modeUnchangedDoes not react
Automatic discount or codeUnchangedDoes not react
Prices edited by hand or CSVWhatever you typedFollows, including your typos

If you want a discount-based sale and a Sale page, build the collection from a tag or from the same manual collection the discount targets. It is the old manual job, but it is honest about what it is. The comparison of the two modes covers the other differences.

The permanent residents

Open a Sale collection built this way on a store that has been running for a few years and you will usually find products that are not on sale. There are three kinds.

  • Products with a standing compare-at price. Some stores keep a recommended retail price in compare-at all year. Those products are always in the collection. When a SafeSale sale touches them, the preview warns that the existing compare-at will be replaced for the duration and restored afterwards, and it is, so they stay in the collection before, during and after. Our post on products that already have a compare-at price explains what the shopper sees.
  • One stray variant. Someone ran a sale on the red size M two years ago and reset the price but not compare-at. One variant is enough to keep the whole product on the Sale page.
  • Zeros. A CSV import or an app wrote 0 into compare-at. The product page shows nothing odd, because 0 is not higher than the price, but the collection counts it.

You can tighten the collection for the last two. Set it to match all conditions and add a second one, Compare-at price is greater than 0. Zeros drop out. The stray variants need cleaning: export products to CSV, sort by the compare-at column and clear the ones that should be blank. Do it before the sale, not during. An edit made by hand to a variant that is in a running sale is something SafeSale records as an outside change, and the post on prices edited mid-sale describes what happens next.

Do not point the sale at the Sale collection

It is tempting to use the automated Sale collection as the target of the next sale: everything already marked down, take another 10% off. The trouble is that its membership is a result of prices, and the sale is about to change prices. Products join and leave as writes land. A sale target should be a list that does not depend on the sale itself: a manual collection, a tag, a vendor. If the goal is a second markdown on products already reduced, the post on back-to-back sales shows a cleaner way to step prices down.

Sorting and what shoppers see

Because rewrite mode changes the real price, the Sale page sorts and filters by sale prices like any other collection. Price low to high puts the cheapest sale items first. Themes that show a badge or a struck-through price do so from the same two fields, so the grid and the product page agree.

One display rule catches people. On a collection grid, a product only looks discounted when its variants agree. If half the variants are in the sale and half are not, the product is in the Sale collection (one variant is enough for membership) but its card may show the regular price. Shoppers click a Sale page item and see no saving until they pick the right size. When you exclude variants from a sale, check how those products look in the grid.

A ten-minute setup

  1. Create the automated collection with Compare-at price is not empty. Save it and look at what is already inside.
  2. Decide about each resident. Standing compare-at prices are a choice. Stray variants and zeros are clean-up.
  3. Add the collection to the menu, or keep the link hidden until the sale starts if an empty page bothers you.
  4. Create the sale in rewrite mode and stop at the preview. The number of products in the preview is roughly the number that will join the page.
  5. After the sale starts, open the collection in the storefront and count. After it ends, open it again. It should be back to the residents from step two.

The last check is the one worth doing every time. A Sale page that empties itself is evidence that every price went back, which is the question that keeps people awake the night a sale ends. If something is still sitting there the morning after, it is either a resident you already knew about or a variant that needs a look, and the audit log will tell you which.

Frequently asked questions

How do I make a Sale collection in Shopify that updates automatically?

Create a collection, choose the automated (smart) type and add one condition: Compare-at price is not empty. Shopify then includes every product where the product or any of its variants has a value in the compare-at field, and removes it when the field is cleared. Nothing has to be tagged by hand.

Why is my Sale collection empty during an automatic discount?

Because an automatic discount does not write anything to the product. The compare-at field stays as it was, so a collection that looks for compare-at prices finds nothing. The same is true of a SafeSale sale in Shopify Functions mode. If the Sale page has to fill up by itself, run the sale in price-rewrite mode, or tag the products and build the collection from the tag.

Do products leave the Sale collection when a SafeSale sale ends?

Yes, if they had no compare-at price before the sale. When a rewrite sale ends, SafeSale puts back the price and the compare-at value it recorded in the snapshot. For a product whose compare-at was blank, the field goes back to blank and the collection drops it. A product that already had a compare-at price before the sale gets that value back and stays in the collection, as it was before.

Why is a full-price product showing in my Sale collection?

Usually because one variant has a leftover compare-at value. Shopify counts any value as not empty, including 0, and one variant is enough to pull in the whole product. Open the product, look at compare-at on every variant and clear the stray one so the field is blank.