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
- Use
@payloadcms/plugin-ecommerce's PriceCell for a number field that can legitimately be 0
- Set the field value to
0
- View the collection list view
- 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".
Description
The
PriceCellcomponent in@payloadcms/plugin-ecommerceuses a falsy check (!cellData) to determine if a price is set. This causes0to be treated as "not set", displaying thepriceNotSettranslation (e.g. "Preis nicht festgelegt.") instead of formatting0as a valid price (e.g. "€0.00").Reproduction
@payloadcms/plugin-ecommerce'sPriceCellfor a number field that can legitimately be00Root Cause
In
packages/plugin-ecommerce/src/ui/PriceCell/index.tsx, line 21:!cellDataistruewhencellDatais0, which is a valid price.Suggested Fix
Replace the falsy check with an explicit
null/undefinedcheck:Use Case
We use
PriceFieldfor a gift cardcurrentBalancefield. When a gift card is fully redeemed (balance = 0), the list view incorrectly shows "Preis nicht festgelegt." instead of "€0.00".