Sub topic 9
Handling out-of-stock, changed, and discontinued products
This chapter covers what to do with a product page when the product's state changes. It assumes you know the basics of schema.org JSON-LD, the idea of a single source of truth for facts, and how HTTP status codes and caches work. Earlier chapters showed how to mark up an Offer and keep the markup in line with the visible page. Here the focus is on the three situations where that work most often breaks: stock runs out, details change, and a product is withdrawn for good.
Why these states need their own handling
A product page is a promise. It says "you can buy this, at this price, with these features." When any part of that promise stops being true, every system that read the page earlier keeps repeating the old version. That includes search results, AI answers that quote the page, shopping listings, and bookmarks.
Each situation has a different cost:
- Out of stock is usually temporary. The page should stay, but say so clearly.
- Changed means the product still exists but a fact differs: price, size, material, version, or bundle contents.
- Discontinued is permanent. The page needs a deliberate exit plan.
Treating all three the same way (for example, leaving the page untouched, or deleting it) is the most common error.
The three product states
The following diagram shows how a product page moves between states and what each move should trigger.
Notice that "Changed" is not a permanent state. It is a window during which the source record, the visible page, the markup, the caches, and the feeds are being brought back into agreement. The goal is to keep that window short.
Out-of-stock products
Keep the page, change the signals
If a product will return, keep the URL. The page has accumulated links, reviews, and history, and removing it throws that away. What you change is the availability signal, in two places that must agree.
Visible content. Replace the buy button with a clear message, such as "Currently out of stock". If you can offer one, add a "notify me" form or a link to alternatives. Do not hide the price silently, and do not leave an active "Add to cart" button that fails at checkout.
Structured data. Set availability in the Offer to a value that matches reality. The common values are:
| Situation | schema.org value |
|---|---|
| Available now | `https://schema.org/InStock` |
| Temporarily unavailable | `https://schema.org/OutOfStock` |
| Can be ordered, ships later | `https://schema.org/BackOrder` |
| Not yet released, orderable | `https://schema.org/PreOrder` |
| Withdrawn permanently | `https://schema.org/Discontinued` |
The generator below derives the value from inventory and lifecycle fields in the product record. Because the page text is produced from the same record, the two cannot disagree.
from decimal import Decimal
import json
AVAILABILITY = {
"in_stock": "https://schema.org/InStock",
"out_of_stock": "https://schema.org/OutOfStock",
"backorder": "https://schema.org/BackOrder",
"discontinued": "https://schema.org/Discontinued",
}
def stock_state(p):
if p["discontinued"]:
return "discontinued"
if p["inventory"] > 0:
return "in_stock"
return "backorder" if p["accepts_backorders"] else "out_of_stock"
def stock_message(p):
return {
"in_stock": "In stock",
"out_of_stock": "Currently out of stock",
"backorder": "Available on backorder",
"discontinued": "This product has been discontinued",
}[stock_state(p)]
def product_jsonld(p):
return {
"@context": "https://schema.org",
"@type": "Product",
"name": p["name"],
"sku": p["sku"],
"offers": {
"@type": "Offer",
"price": str(p["price"]),
"priceCurrency": p["currency"],
"availability": AVAILABILITY[stock_state(p)],
},
}
product = {
"name": "Trail Runner 2",
"sku": "TR2-BLK-42",
"price": Decimal("89.00"),
"currency": "EUR",
"inventory": 0,
"accepts_backorders": False,
"discontinued": False,
}
print(stock_message(product))
print(json.dumps(product_jsonld(product), indent=2))Common errors with stock
- Marking "InStock" in a template default. If the markup is a static block and only the visible text changes, the page claims availability it does not have.
- Flipping to "OutOfStock" for a few minutes of sync lag. Brief inventory glitches then ripple into feeds and caches. Add a small buffer or confirm the zero before publishing the change.
- Returning 404 for a temporarily unavailable item. This signals that the page is gone, and you lose the page's standing for no reason.
- Leaving
priceValidUntilin the past. An expired validity date on a live offer contradicts the page. Remove it or renew it with each price review.
Changed products
A change is a fact edit on a product that continues to exist. Price is the most frequent, but descriptions, specifications, variants, and bundle contents change as well.
Update the record once, then propagate
Edit the single source record. Everything downstream should then follow without hand edits: the visible price, the JSON-LD, the product feed, and any comparison tables. If someone must edit three places by hand, one of them will be missed.
After the edit, run through this order:
- Change the source record.
- Regenerate the page and its markup.
- Purge caches and CDN copies for that URL (see the caching chapters).
- Update
dateModifiedand the sitemaplastmodif the change is meaningful. - Let the product feed pick up the new values on its next run, or trigger a refresh.
What counts as a meaningful change
A price or availability change is meaningful for the product, since it alters what a buyer would decide. A fixed typo in a footer is not. For product pages, bump dateModified and lastmod when a fact a buyer relies on changes: price, availability, specifications, compatibility, warranty, or what is in the box. Do not bump them when you adjust layout, reorder related links, or run a site-wide template change.
Be careful with variants and old identifiers
If a change creates a new version (for example, "Trail Runner 3" replaces "Trail Runner 2"), decide whether it is the same product with new facts or a different product. Use these criteria:
- Same SKU, same purpose, small improvement: edit in place and keep the URL.
- New SKU or materially different specification: treat it as a new product with a new page, and treat the old one as discontinued.
Reusing an old URL and SKU for a different product causes confusing history. Old reviews, links, and feed entries then describe something that no longer matches.
Price changes in markup
When a price changes, the Offer price and the visible price must change together, and the old price must not remain anywhere else on the page, such as in a "from" snippet, a related-products card, or a cached fragment. If a sale has an end date, state it in priceValidUntil and make sure the visible page reflects the end of the sale on time. A sale that ends on the page but not in the markup is a mismatch.
Discontinued products
Discontinuation is permanent, so the page's job changes. Choose one of the paths below based on whether a successor exists and whether the old page still has value.
| Situation | Recommended handling | HTTP response |
|---|---|---|
| Direct successor exists | Redirect to the successor's page | 301 |
| No successor, but a category fits | Redirect to the category only if the match is close | 301 |
| No successor, page has lasting value (manuals, parts, support) | Keep the page, mark it discontinued, link to support and alternatives | 200 |
| No successor, no value | Remove the page | 410, or 404 |
Redirect only to relevant pages
A redirect tells crawlers and AI systems that the new page is the replacement. Sending every retired product to the home page misleads people, and search engines may treat it as a soft 404. Redirect when the destination answers the same need. Otherwise choose another path.
Keeping a discontinued page
Keep the page when people still search for the product to find spare parts, manuals, or compatibility details. Make the state unmistakable:
- State at the top that the product is discontinued.
- Remove any buy button and any live price.
- Set
availabilitytohttps://schema.org/Discontinued. - Link to the successor or to alternatives.
Do not leave the old price in the markup. A discontinued product with a live-looking offer is a stale fact that can be quoted back to buyers long after it was true.
Removing a page: 410 versus 404
Both mean the page is not there. A 410 Gone states that the removal is deliberate and permanent, which can help crawlers drop the URL sooner. A 404 Not Found is acceptable and more common. Whichever you use, also remove the URL from the sitemap and from product feeds, otherwise you keep advertising an address that fails.
HTTP/1.1 410 Gone
Cache-Control: public, max-age=3600
Content-Type: text/html; charset=utf-8A short cache lifetime on the error response lets you reverse the decision quickly if the product returns.
Cleaning up after a retirement
Retirement touches several places beyond the page itself. Work through this list each time:
- Update the source record's lifecycle status first.
- Apply the redirect, the discontinued page, or the 410.
- Remove the URL from the sitemap, or keep it only if the page stays live.
- Remove the item from product feeds.
- Update internal links, related-product lists, and category pages.
- Purge caches for the old URL and for pages that listed it.
Edge cases
- Seasonal products. If an item returns every year, keep the page and mark it out of stock between seasons rather than discontinuing it.
- Marketplace sellers. If stock depends on a third party, make sure the sync interval is short, since a slow sync leaves "InStock" on a product you cannot ship.
- Multiple variants. One size may be sold out while others are available. Give each variant its own
Offerwith its own availability, and make the visible selector show the same states. - Price changes mid-cache. A page cached for five minutes can show the old price for up to five minutes. Accept that window deliberately, or purge on change.
Summary of decisions
- Temporary shortage: keep the URL, update visible text and
availability, return 200. - Fact change: edit the source, regenerate, purge caches, update dates if meaningful.
- Replacement exists: 301 to the successor.
- Page still useful but product gone: keep it, mark
Discontinued, remove the offer. - Nothing worth keeping: 410 or 404, and remove from sitemap and feeds.
Exercise
A store retires "Trail Runner 2" and launches "Trail Runner 3", which has a new SKU and a different sole. The old page still receives search traffic and has many reviews. Describe what you do with the old URL, the markup, the sitemap, and the product feed.
Show answer
Treat Trail Runner 3 as a new product with its own page. Because a direct successor exists, send the old URL to the Trail Runner 3 page with a 301 redirect. If you want to keep the old page for owners who need support information, keep it at 200 instead, mark it discontinued, set availability to https://schema.org/Discontinued, remove the live price and buy button, and link to the successor. In both cases, update the source record's lifecycle status first, remove the old URL from the sitemap if it redirects (keep it only if the page stays live), remove the old SKU from the product feed, and purge caches for the old URL and any category pages that listed it.
Exercise
A product page shows "Currently out of stock" in the visible text, but a template default leaves "availability" set to https://schema.org/InStock in the JSON-LD. Why is this a problem, and how would you prevent it from recurring?
Show answer
The markup and the visible page disagree, so search engines, shopping systems, and AI answers may tell buyers the item is available when it is not, and feed or listing checks may reject the item. Prevent it by generating both the visible message and the JSON-LD availability from the same lifecycle and inventory fields in the product record, so one value drives both. Add an automated check that compares the markup's availability with the visible stock message on rendered pages.