SafeSale · Blog

Sale ends while items sit in a cart: what the shopper pays

A Shopify cart holds variants, not prices. What a shopper pays when a sale ends between add to cart and payment, in discount mode and in price-rewrite mode.

Every sale has a last minute, and in that minute there are shoppers with a full cart. Some are reading the shipping options. Some have a tab open from the afternoon. One is typing a card number as the clock turns over. The question they will all ask, if the price moves under them, is the one in the title: what do I pay? The answer depends on a fact about Shopify carts that most people never need to know, and on which of SafeSale's two sale modes you used.

A cart is a list of variants, not a list of prices

When a shopper adds a product to a Shopify cart, the store records the variant and the quantity. It does not record the price. Each time the cart page, the cart drawer or the checkout is rendered, Shopify looks up the current price of each variant and shows that. The same goes for automatic discounts: they are evaluated against the cart when the page is built, not stored in it.

That is why a cart can quietly change between two page loads. A product that cost 48 at 15:00 and 60 at 15:05 shows 48 in the tab left open at 15:00 and 60 the moment that tab is refreshed or the shopper proceeds to checkout. The shopper did not do anything wrong, and neither did the store; the cart simply never held a price to protect. The payment step prices the order from what is true at that moment, which is the only price Shopify can defend.

So the real question is not "what was in the cart" but "what was the variant's price, and was the discount still active, at the second the checkout was priced". SafeSale's two modes answer that differently.

Automatic-discount mode: the end is exact

In automatic-discount mode SafeSale does not touch any price. It creates an automatic discount in your store with the sale's start and end times, and a Shopify Function applies the right percentage to each cart line at checkout. Shopify enforces those times itself. At 23:59:59 the discount applies; at 00:00:00 it does not, and no SafeSale process has to run for that to be true.

For a shopper in the last minute, that means:

  • A checkout priced before the end time gets the discount. Once the order exists, its prices are fixed; nothing that happens afterwards changes an order.
  • A checkout priced after the end time does not get it, even if the cart was filled an hour earlier and the cart page still showed the discount in a stale tab. The discount line simply is not there when Shopify prices the order.
  • A shopper sitting in checkout across the boundary sees the total change when the checkout recalculates, which it does before taking payment. They are not charged a different amount from the one shown at the payment step; they are shown the new amount.

After the end time SafeSale's scheduler, which runs every 30 seconds, picks up the sale and tidies up: it deletes the discount, writes a DISCOUNT_DELETE row to the sale's audit log, and unpublishes the metafields the sale badges read, so the badges disappear on the next page view. None of that affects pricing; Shopify stopped applying the discount at the end time on its own. The tidy-up is bookkeeping.

Price-rewrite mode: the end is a sequence

In price-rewrite mode the sale price is the variant's actual price, with the old price parked in compare-at. Ending the sale means writing the old prices back, one product at a time, from the snapshot SafeSale took before the sale started. The timing post covers how long that takes at the start; the end is the same work in reverse.

Two delays stack up. The scheduler checks for due sales every 30 seconds, so a sale ending at 00:00:00 is noticed somewhere between 00:00:00 and 00:00:30. Then the restore runs product by product, and a few hundred variants usually finish within a minute or two. A sale over thousands of variants takes longer, and Shopify's API rate limits can stretch it on a busy night.

For the shopper this means the sale does not end at midnight. It ends, for each variant, at the moment that variant is restored, and the audit log records that moment as a REVERT row with the variant and the prices written. A checkout priced at 00:00:40 for a product restored at 00:01:10 paid the sale price, legitimately: that was the price in the store when the order was created. A checkout at 00:01:30 for the same product paid full price.

Compare-at follows the same sequence. While a variant is still unrestored, the product page shows the sale price with the old price struck through; after the restore, compare-at goes back to whatever it was in the snapshot, which for most products is empty. A shopper who screenshots the product page at 00:00:50 has a true picture of the store at that second.

Side by side

MomentAutomatic discountPrice rewrite
Checkout priced before the end timeSale priceSale price
Checkout priced seconds after the end timeFull priceSale price until that variant is restored
Checkout priced a few minutes afterFull priceFull price for most or all variants
Stale cart tab from before the endShows discount until refreshed; checkout re-pricesShows old price until refreshed; checkout re-prices
Order already placedUnchangedUnchanged

Neither mode is wrong here. The automatic discount gives you a hard edge, which is what a legal "ends midnight" claim wants. The rewrite gives you a soft edge of a minute or two, which in practice works in the shopper's favour and costs you a handful of orders at the sale price. What you should not do is promise a hard edge and run a rewrite over thousands of variants, because the last products restored will be visibly on sale for several minutes past the time on the banner.

The time on the banner and the time in the sale

SafeSale ends a sale at the end time you entered, interpreted in the store's time zone (the time zone post has the details). Nothing requires that time to match the one you advertise. Three habits follow from that.

  • Add a grace period. Announce "ends midnight" and set the end time to 00:15. Every shopper who reached checkout before midnight has a quarter of an hour to finish, in either mode, and the few who add to cart at 00:05 get a small gift rather than a complaint. The grace period is a decision you make once per sale, in the end time field.
  • End in a quiet hour. If the exact minute does not matter to the campaign, end at 03:00 rather than 00:00. Fewer carts are open, the rewrite finishes while nobody is watching, and your support inbox is empty in the morning.
  • Do not end during a traffic peak. A sale that ends at 20:00 on a Sunday ends while the store is at its busiest, and in rewrite mode the restore competes with that traffic for API capacity. If the campaign demands it, use automatic-discount mode for the hard edge.

When a shopper writes in

The message usually reads: it was in my cart at the sale price, and at checkout it was full price. Everything above says the store behaved correctly, and almost nothing above helps the conversation. Two things do.

First, look it up. The order's timestamp is on the order page; the sale's end time is on the sale page; in rewrite mode the exact restore time for the variant is in the audit log. In thirty seconds you know whether the shopper paid full price two minutes or two hours after the end, which changes how generous you want to be.

Second, decide the policy before the sale. A one-off discount code for the difference, sent with a short note, resolves nearly every case and is cheaper than the second email. If you find yourself sending many of them, the sale ended at the wrong hour or without a grace period, and the fix is in the end time of the next one, not in the inbox.

The reverse case

The same mechanics run the other way at the start. A shopper with a cart from Thursday who comes back on Friday after the sale begins sees the sale price when the cart renders, in either mode, because the cart never held Thursday's price. In rewrite mode the first products become cheaper within a minute or two of the start time and the last ones a little later; in automatic-discount mode the discount appears at the start time exactly. Nobody writes in about this one, which tells you something about how the cart really works: it is always priced now, and a sale is a change to what now costs.

Frequently asked questions

If a shopper adds a sale item to the cart before the sale ends, do they keep the sale price?

Not automatically. A Shopify cart stores which variants are in it, not what they cost; the price is looked up when the cart or checkout is rendered. In automatic-discount mode the discount stops applying at the sale's end time, and in price-rewrite mode the price goes back as soon as SafeSale restores that variant, usually within a minute or two of the end time. Whatever the checkout shows at the moment of payment is what the shopper pays.

Why did an order come in at the sale price a minute after the sale ended?

In price-rewrite mode the restore is a sequence of writes, one product at a time, that starts at the first scheduler check after the end time (up to 30 seconds later) and takes a minute or two for a few hundred variants. A checkout completed before a given variant was restored paid the sale price. The sale's audit log shows the exact restore time per variant, so you can see which side of it the order fell on.

Can I give a grace period so shoppers mid-checkout at midnight still get the discount?

Yes, by setting the end time later than the time you advertise. Announce midnight, set the sale to end at 00:15 store time, and anyone who reached checkout before midnight has fifteen minutes to pay. SafeSale ends the sale at the time in the sale, not the time on the banner, so the banner is yours to word as you like.

A customer says the price changed while they were paying. What should I do?

Check the order time against the sale's end time and the audit log. If they paid a few minutes after the end, the honest answer is that the sale had ended; most merchants still refund the difference or send a one-off discount code, which costs less than the argument. If you expect many of these, move the end time to a quiet hour or add a grace period for the next sale.