#Specifying decimals while using priceInUSD (Payload eCommerce template)
8 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
Can you share a snippet of your code so I can diagnose this better? Thanks!
Using the official ecommerce template. Added USD as a supported currency to this file: https://github.com/payloadcms/payload/blob/main/templates/ecommerce/src/plugins/index.ts
ecommercePlugin({
access: {
adminOnlyFieldAccess,
adminOrPublishedStatus,
customerOnlyFieldAccess,
isAdmin,
isDocumentOwner,
},
currencies: {
supportedCurrencies: [
USD,
{
code: 'USD',
decimals: 0,
label: 'US Dollar',
symbol: '$',
},
],
defaultCurrency: 'USD',
},
...
I just want USD to be the primary currency and to not have any decimals on the prices.
Ahh, ok
The error is from listing USD twice in supportedCurrencies — once as the imported USD constant and once as the custom override
the ecommerce plugin generates per-currency fields like priceInUSDEnabled keyed off the code, so two entries with code: 'USD' produce two priceInUSDEnabled fields at the same level