payloadcms/payload · error · Error
MissingPrice
MissingPrice
Error message
Product does not have a price in.
What it means
Thrown by defaultProductsValidation when no variant is supplied and the product itself has no value for the dynamic price field priceIn<CURRENCY>. The error carries an ErrorOptions cause with code 'MissingPrice' and codes [product.id, currency], so callers can inspect error.cause.code to distinguish it from a generic failure. Note the message text 'Product does not have a price in.' is truncated — the currency is not interpolated, but the cause.codes carries it.
Source
Thrown at packages/plugin-ecommerce/src/utilities/defaultProductsValidation.ts:31
throw new Error('Currency must be provided for product validation.')
}
const priceField = `priceIn${currency.toUpperCase()}`
if (variant) {
if (!variant[priceField]) {
throw new Error(`Variant with ID ${variant.id} does not have a price in ${currency}.`)
}
if (variant.inventory === 0 || (variant.inventory && variant.inventory < quantity)) {
throw new Error(
`Variant with ID ${variant.id} is out of stock or does not have enough inventory.`,
)
}
} else if (product) {
// Validate the product's details only if the variant is not provided as it can have its own inventory and price
if (!product[priceField]) {
throw new Error(`Product does not have a price in.`, {
cause: { code: MissingPrice, codes: [product.id, currency] },
})
}
if (product.inventory === 0 || (product.inventory && product.inventory < quantity)) {
throw new Error(`Product is out of stock or does not have enough inventory.`, {
cause: { code: OutOfStock, codes: [product.id] },
})
}
}
}
View on GitHub (pinned to 00c58b35c0)
Solutions
- Backfill priceIn<CURRENCY> on the product for the requested currency.
- Limit checkout currencies to those the product is priced in; hide the product otherwise.
- Add an admin validation hook requiring all configured currency price fields on product create/update.
- Inspect error.cause.code === 'MissingPrice' and error.cause.codes to surface a precise message to the customer.
Example fix
// before: product missing priceInEUR
const product = { id: 1, priceInUSD: 2000 } // EUR checkout fails with MissingPrice
// after: backfill the price
const product = { id: 1, priceInUSD: 2000, priceInEUR: 1850 } Defensive patterns
Strategy: try-catch
Validate before calling
function productHasPriceInCurrency(product: Record<string, unknown>, currency: string): boolean {
const field = `priceIn${currency.toUpperCase()}`
const v = product[field]
return typeof v === 'number' ? v > 0 : Boolean(v)
}
if (!productHasPriceInCurrency(product, currency)) {
const e = new Error(`Product ${product.id} has no price in ${currency}`)
;(e as any).cause = { code: 'MissingPrice', codes: [product.id, currency] }
throw e
} Type guard
export function productHasPrice(product: Record<string, unknown>, currency: string): boolean {
const v = product[`priceIn${currency.toUpperCase()}`]
return typeof v === 'number' ? v > 0 : Boolean(v)
} Try / catch
try {
defaultProductsValidation({ currency, product, quantity })
} catch (err) {
const cause = (err as Error & { cause?: { code?: string } }).cause
if (cause?.code === 'MissingPrice') {
// data gap — backfill or hide the product for this currency
return { ok: false, reason: 'product-missing-price', productId: product.id, currency }
}
throw err
} Prevention
- Backfill priceIn<CURRENCY> on products whenever a new currency is added to currenciesConfig.
- Add an admin hook requiring all configured currency price fields on product create/update.
- Restrict checkout currencies to those the product is priced in; hide unsupported combinations.
- Inspect error.cause.code === 'MissingPrice' to distinguish this from generic validation failures.
When it happens
Trigger: A cart item references a product (no variant) whose priceIn<CURRENCY> field is unset/falsy for the selected currency. Triggered during cart/checkout validation in the product branch.
Common situations: Multi-currency product with prices for some currencies but not the one selected; product created without all configured price fields; a currency added to currenciesConfig without backfilling existing products; data import that omitted price fields; frontend allowing checkout in an unsupported currency for that product.
Related errors
- Variant with ID ${variant.id} does not have a price in ${cur
- Currency must be provided for product validation.
- OutOfStock
- Currency is required.
- Circular reference detected: the parent chain contains a loo
AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12).
Data as JSON: /api/errors/4dcdbc964b59d3f7.
Report an issue: GitHub.