Sub topic 7
Marking up prices, availability, and product details
This chapter covers how to express a product's price, stock status, and identifying details in schema.org JSON-LD. It assumes you know basic HTML, can read JSON, and have seen the idea of a single source of truth from earlier chapters. Here the focus is on the Product and Offer types, the fields that matter, and the errors that make markup wrong or untrustworthy.
What Product markup is for
Search engines, shopping surfaces, and AI answer systems read structured data to extract facts without guessing from page layout. A price in a <span> could be a list price, a sale price, or a shipping fee. A price in an Offer object is labelled as the price of this product, in this currency, with this availability.
Markup does not replace visible content. It restates the visible facts in a form a machine can parse. If the two disagree, the page is less trustworthy, and a system that checks them may ignore the markup or the page.
The shape of a Product with an Offer
A Product describes the thing. An Offer nested inside it describes the terms on which you sell it right now.
{
"@context": "https://schema.org",
"@type": "Product",
"name": "Trail Runner 2",
"sku": "TR2-BLK-42",
"offers": {
"@type": "Offer",
"url": "https://example.com/p/trail-runner-2",
"price": "89.00",
"priceCurrency": "EUR",
"priceValidUntil": "2026-12-31",
"availability": "https://schema.org/InStock"
}
}Each field has a job:
| Field | Meaning | Common mistake |
|---|---|---|
| `name` | Product name as shown on the page | Using a marketing slogan instead of the name |
| `sku` | Your internal stock-keeping unit, unique per variant | Reusing one SKU across sizes or colours |
| `offers.price` | Numeric price as a string, no currency symbol or thousands separator | Writing `"€89,00"` or `"1,299.00"` |
| `offers.priceCurrency` | ISO 4217 code such as `EUR` or `USD` | Writing the symbol instead of the code |
| `offers.priceValidUntil` | Date after which the price should no longer be trusted | Leaving a past date in place |
| `offers.availability` | Full schema.org URL for the stock state | Writing free text such as `"in stock"` |
| `offers.url` | Canonical URL of the page where the offer applies | Pointing at a different variant or a redirect |
Price: format rules that cause real errors
Use a plain decimal number with a period as the decimal separator. Do not include a currency symbol, a space, or a thousands separator. The visible page may show 89,00 € for a German reader. The markup still says "89.00" and "EUR".
Keep the price as a string or number consistently. Many generators emit a string to avoid floating-point surprises. In your own code, store prices as exact decimals or integer minor units (cents), never as binary floats. A float such as 0.1 + 0.2 gives 0.30000000000000004, and that value could end up in your markup.
Availability values
The availability field takes an ItemAvailability value written as a full URL. The ones you will use most are:
https://schema.org/InStock: can be bought now.https://schema.org/OutOfStock: cannot be bought now, and no date is promised.https://schema.org/PreOrder: can be ordered before release.https://schema.org/BackOrder: can be ordered, but shipping is delayed.https://schema.org/Discontinued: no longer made or sold.https://schema.org/LimitedAvailability: a small quantity remains.
Choose the value from real inventory data, not from a template default. A template that hard-codes InStock is one of the most common ways a site tells machines something false.
Generating markup from the source of truth
The safest approach is to build both the visible label and the JSON-LD from the same product record. They then cannot drift apart. This example does that and maps the stock flag to the correct URL.
from decimal import Decimal
import json
def product_jsonld(p):
availability = 'https://schema.org/InStock' if p['in_stock'] else 'https://schema.org/OutOfStock'
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,
},
}
def price_label(p):
return ' '.join([str(p['price']), p['currency']])
product = {'name': 'Trail Runner 2', 'sku': 'TR2-BLK-42', 'price': Decimal('89.00'), 'currency': 'EUR', 'in_stock': True}
print(price_label(product))
print(json.dumps(product_jsonld(product), indent=2))Running it prints 89.00 EUR followed by the JSON-LD. Note that Decimal('89.00') keeps its two decimal places when converted with str, so the markup says "89.00" and not "89.0". The code uses Decimal for that reason.
This version handles only two stock states. A real catalogue also needs preorder, backorder, and discontinued states. Extend the mapping with a lookup table keyed on an inventory status field rather than a growing chain of if statements.
Variants: one offer per sellable item
A shoe in three sizes and two colours is six sellable items, and each has its own SKU, stock level, and possibly price. Two patterns are in common use:
- One page per variant, each with its own
Productand a singleOffer. This is simple and each URL maps to exactly one SKU. - One page for the product family, using
ProductGroupwithhasVariantentries, or aProductwith severalOfferentries. This is more expressive but easier to get wrong.
If a page shows one price but the markup lists several offers with different prices, a parser cannot tell which one the visitor sees. Whichever pattern you use, the markup should reflect what the page presents as the current choice, and each offer should carry its own correct availability.
Sale prices and price ranges
For a discounted item, the Offer price should be the price the customer actually pays now. Do not put the crossed-out list price in price. If you want to describe the original price, use a priceSpecification that is clearly marked as a list price, and only if the visible page shows it too.
When a family of variants has different prices, an AggregateOffer with lowPrice, highPrice, priceCurrency, and offerCount can summarise the range. Use it only when the page itself shows a range. Do not use it to hide uncertainty about a single item's price.
Expiry: priceValidUntil
priceValidUntil says when the stated price stops applying. It is useful for time-limited sales. It is harmful when left as a fixed past date, because the markup then claims a price that has formally expired.
Two safe approaches:
- Set it only for real promotions with a known end date, and remove or replace it when the promotion ends.
- Compute it from the promotion record in your source of truth so it is never typed by hand.
A permanent price needs no expiry value. Omitting the field is more honest than setting a date a year out that nobody will revisit.
Product details beyond price
Identity fields help systems match your page to the same product elsewhere. Add the ones you truly have:
brand: aBrandobject with aname.gtin13or another GTIN property,mpn: global identifiers from the manufacturer.image: absolute URLs of images that show the product.description: text that matches the visible description.color,size,material: only when stated on the page.
Do not invent identifiers. A made-up GTIN is worse than none, because merchant platforms use it to match listings and may reject or flag the item.
Validation and checking
Syntax errors are the cheap failures. A trailing comma or a missing quote makes the whole block unreadable. Parse your generated output in a test before it ships.
import json
import re
def check_offer(markup: str) -> list[str]:
problems = []
data = json.loads(markup)
offer = data.get('offers', {})
price = str(offer.get('price', ''))
if not re.fullmatch(r'\d+(\.\d{1,2})?', price):
problems.append('price is not a plain decimal: ' + price)
if not re.fullmatch(r'[A-Z]{3}', offer.get('priceCurrency', '')):
problems.append('priceCurrency is not a three-letter code')
if not str(offer.get('availability', '')).startswith('https://schema.org/'):
problems.append('availability is not a schema.org URL')
return problems
sample = '{"@type":"Product","offers":{"price":"89.00","priceCurrency":"EUR","availability":"https://schema.org/InStock"}}'
print(check_offer(sample))This prints an empty list for the sample. It catches format errors only. It cannot tell whether 89.00 is the price shown on the page. That comparison is the subject of the next chapter.
Common errors
- Hard-coded availability. The template says
InStockfor every product, including sold-out ones. - Currency symbol in price. The value
"€89"fails parsing. - Stale
priceValidUntil. A past date stays in the page after a promotion ends. - Markup for content that is not on the page. Reviews, ratings, or offers that visitors cannot see.
- Multiple conflicting Product blocks. A theme and a plugin each emit their own, with different prices.
- Cached markup. The visible price updates but a cache serves old JSON-LD. Caching is covered in later chapters.
How the data flows
Exercise
A product page shows "1.299,00 €" to the visitor, and the item is sold out. Write the correct price, priceCurrency, and availability values for the Offer, and say which one the template most likely gets wrong.
Show answer
"price": "1299.00", "priceCurrency": "EUR", "availability": "https://schema.org/OutOfStock". The price uses a period and no thousands separator, and the currency is a code, not a symbol. The availability is the value templates most often get wrong, because a hard-coded InStock default stays in place when stock reaches zero.
Exercise
Your sale ended on 2026-10-31, but the page still contains "priceValidUntil": "2026-10-31" in November. Why is this a problem, and how do you prevent it?
Show answer
The markup claims the price has expired, so machines may distrust the price or drop the offer. Prevent it by deriving priceValidUntil from the promotion record in the source of truth, and omitting it when no promotion is active, so no one types the date by hand.