Deleted a product during a Shopify sale: what happens
What a sale app should do when a product or variant disappears mid-sale: how SafeSale skips it on apply, closes its snapshot on restore, and what to watch for.
By Beacon Wave Studio · · 7 min read
A sale is live, three hundred variants have a struck-through price, and someone on the team deletes a product. Maybe it was a duplicate, maybe the supplier discontinued it, maybe it was a mistake. The question that follows is quieter than the one about prices changing, but it matters just as much: what does the sale app do when a thing it wrote to no longer exists?
The honest answer for a lot of tools is that they throw an error, stop, or keep retrying a write that can never succeed. This post explains what SafeSale does instead, at each of the three moments where a missing product can show up: while the sale is applying, while it is running, and when it ends and prices are restored. It also covers the two cases people confuse with deletion, archiving and recreating, which behave very differently.
Two mechanisms, two very different exposures
SafeSale runs a sale in one of two ways. As an automatic discount, built on Shopify Functions, the sale never edits your catalog: the discount is evaluated in the cart and at checkout against whatever products exist at that moment. Delete a product and it drops out of the discount the same way it drops out of the storefront. There is nothing to clean up, and when the sale ends SafeSale deletes the discount and logs it.
As a price rewrite, the sale does edit the catalog. Every variant in the preview gets its original price and compare-at price stored in a snapshot, then its price field is changed, and at the end the snapshot is written back. A deleted variant is a snapshot row that points at nothing. Everything below is about this mechanism, because it is the one where a missing product could leave a mess if the app were careless.
Deleted while the sale is applying
Applying is not one big write. SafeSale works through the sale in batches, and before each batch it asks Shopify for the current price and compare-at price of the variants in it. That live read is there for a different reason, to skip variants that already carry the sale price so a retried job never writes twice, but it also answers the deletion question for free. A variant that was deleted since the preview is missing from the answer.
When that happens the app marks the snapshot row as applied without writing anything, and continues with the rest of the batch. There is no error, no retry, and no stalled sale. The progress counter on the sale page, shown as applied over total, still reaches the total, because the deleted variant is counted as handled rather than left pending forever.
One subtlety: the snapshot was taken first, before any price was changed, so the deleted variant does have a snapshot row with its original prices in it. That row stays in the database and appears in the snapshot CSV like any other. If you ever need to know what a product cost before you deleted it, that is where to look.
Deleted while the sale is running
Once a variant has its sale price, SafeSale has no reason to touch it again until the end. Deleting it in the middle of the sale therefore does nothing immediately. The app subscribes to product update webhooks to catch prices edited by hand during a sale, but a deletion is not an update, and the app does not need to react to it: the variant is gone, its sale price went with it, and the only remaining trace is the snapshot row waiting for the end of the sale.
Nothing in the sale changes either. Variant and product counts on the sale page reflect the preview that was confirmed, and the sale keeps running for everything else until its end time or until you end it.
Deleted before the restore
Ending a sale restores every snapshot row that has not been restored yet. The restore does the same live read as the apply: fetch the current prices of every variant with an open snapshot, then compare. Two kinds of row need no write. One is a variant whose live price and compare-at already equal the snapshot, usually because someone restored it by hand or because a retry already did the work. The other is a variant that no longer exists.
Both kinds are closed the same way: the row is stamped as restored and no mutation is sent. The change log entry for the end of the sale then reads, for example, Restored 297 variants to their original prices (3 already matched). The three are the hand-restored ones and the deleted ones together. The number of REVERT rows in the audit log equals the restored count, not the total, because only real writes are logged as writes.
This is also why the store-wide Restore all original prices button is safe to press after a clear-out. It walks every open snapshot in the store, and a snapshot whose variant is gone costs one read and a timestamp. It cannot fail on a product you deleted last month.
Archiving is not deleting
Merchants often archive a product to take it off sale mid-campaign, and then wonder whether the sale app has lost track of it. It has not. An archived product keeps its variants and its variant IDs; archiving changes the product status and removes it from sales channels, nothing more. SafeSale sees exactly the same variant it saw before.
That cuts both ways. If the product was in the preview, its sale price is applied whether or not it is archived at the time, and its original is restored at the end. If you archive a product to stop it being discounted, the discount still sits on it in the admin, invisible to shoppers only because the product is unpublished. Unarchive it during the sale and it reappears at the sale price. If the intent is to leave it out of the sale entirely, the clean route is a per-variant override at 0% before confirming, as described in the post on different discounts per variant.
Recreating and duplicating
The case that does bite is a product that is deleted and then recreated, or duplicated during the sale. Shopify assigns new variant IDs in both cases, and SafeSale has no snapshot for them.
- Deleted and recreated. The new product has whatever prices you typed when you built it again. It is not in the sale, it will not be discounted, and nothing will be restored on it at the end. If it belongs in the sale, the way in is a new sale that targets it.
- Duplicated while the sale is live. Duplicate copies the current prices, which during a price rewrite are the sale price and the sale compare-at. The copy therefore starts life looking like it is on sale, with no snapshot behind it, and when the original is restored the copy keeps the discounted numbers. Check duplicates made during a sale and fix their prices by hand, or make the duplicate after the sale ends.
Neither of these is specific to SafeSale. Any tool that stores original prices against a variant ID, which is the only sane way to store them, loses the thread when the ID changes. The difference is whether the tool tells you, and the snapshot CSV, which lists each original by variant and by handle, is the record to compare against.
A short checklist for clear-outs during a sale
- Deleting a product mid-sale is safe. The apply skips it, the restore closes its row, the sale finishes normally.
- Archiving does not remove a product from a sale. Use a 0% override at confirmation time if you want it excluded, or end the sale and start a new one without it.
- Avoid duplicating products while a price rewrite is live, or correct the copy afterwards.
- If you need the pre-sale price of something you deleted, download the snapshot CSV from the sale page. The row is still there.
The pattern behind all of this is one decision made early in SafeSale: every write is preceded by a read of what is actually there, and a variant that is not there is a reason to skip, never a reason to stop. It makes the retry logic simple and, as a side effect, makes deleting things during a sale a non-event.
Frequently asked questions
I deleted a product while a SafeSale price rewrite was applying. Will the sale fail?
No. Before every batch of writes SafeSale reads the live prices of the variants it is about to change. A variant that no longer exists is simply missing from that answer, so the app marks its snapshot row as done and moves on. Nothing is written for it and nothing fails because of it.
What happens at the end of the sale for a variant that was deleted mid-sale?
Restore does the same live read. A variant that cannot be found is treated like one that already matches its original prices: the snapshot row is closed and it is counted under already matched in the change log entry, next to the number of variants that were actually written back.
Does archiving a product behave the same as deleting it?
No. An archived product still exists with the same variants, so SafeSale treats it like any other product: the sale price is applied if the product was in the preview, and the original is restored at the end. Archiving only hides it from your sales channels.
I deleted a product by mistake and recreated it. Does the sale still cover it?
Not automatically. The recreated product has new variant IDs, and SafeSale snapshots are keyed by variant ID. The new product carries whatever price you typed when you recreated it, and no snapshot exists for it, so there is nothing to restore later. Add it to a new sale if it should be discounted.