Skip to content

plugin-ecommerce: PriceCell treats 0 as 'price not set' #15861

@jhb-dev

Description

@jhb-dev

Description

The PriceCell component in @payloadcms/plugin-ecommerce uses a falsy check (!cellData) to determine if a price is set. This causes 0 to be treated as "not set", displaying the priceNotSet translation (e.g. "Preis nicht festgelegt.") instead of formatting 0 as a valid price (e.g. "€0.00").

Reproduction

  1. Use @payloadcms/plugin-ecommerce's PriceCell for a number field that can legitimately be 0
  2. Set the field value to 0
  3. View the collection list view
  4. The cell shows "Preis nicht festgelegt." instead of "€0.00"

Root Cause

In packages/plugin-ecommerce/src/ui/PriceCell/index.tsx, line 21:

if (!cellData) {
    return <span>{t('plugin-ecommerce:priceNotSet')}</span>;
}

!cellData is true when cellData is 0, which is a valid price.

Suggested Fix

Replace the falsy check with an explicit null/undefined check:

if (cellData === null || cellData === undefined) {
    return <span>{t('plugin-ecommerce:priceNotSet')}</span>;
}

Use Case

We use PriceField for a gift card currentBalance field. When a gift card is fully redeemed (balance = 0), the list view incorrectly shows "Preis nicht festgelegt." instead of "€0.00".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions