#Specifying decimals while using priceInUSD (Payload eCommerce template)

8 messages · Page 1 of 1 (latest)

mental nebula
#

Hi all, when I try to modify the decimals of the default USD currency settings within supportedcurrencies I get the error: A field with the name 'priceInUSDEnabled' was found multiple times on the same level. Field names must be unique. Does anyone know how to fix this? Thanks!

gritty cedarBOT
solar quarry
#

Can you share a snippet of your code so I can diagnose this better? Thanks!

mental nebula
#

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',
    },
...
GitHub

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for buildi...

mental nebula
#

I just want USD to be the primary currency and to not have any decimals on the prices.

solar quarry
#

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