When multiple currencies are available, allow configuring the default currency the price widget should use

Created on 28 November 2018, about 6 years ago
Updated 23 January 2025, 12 days ago

Problem/Motivation

When a site has multiple currencies enabled and a user goes to enter price information, the default currency is whatever wins in alphabetical sorting. If a country serves AU, CA, and US then all prices would default to the AUD currency, even though the store may primarily be in the US. This causes additional working during data entry to change the currency value (especially if using price list to control the other currencies pricing.)

Proposed resolution

The commerce_price_default should allow specifying the default currency:

  • Current store's default currency
  • Currency A
  • Currency B
  • Currency C

This can be done by adding an else for an empty field value

    if (!$items[$delta]->isEmpty()) {
      $element['#default_value'] = $items[$delta]->toPrice()->toArray();
    }

An empty price with the default currency can be passed.

Remaining tasks


Test.
Bikeshed wording.

User interface changes

Allows configuring the price field widget and defaulting the currency.

API changes

None

Data model changes

None

✨ Feature request
Status

Needs work

Version

2.0

Component

Price

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024