TypeError: CommerceGuys\Intl\Formatter\CurrencyFormatter::format(): Argument #1 ($number) must be of type string, null given,

Created on 8 August 2023, over 1 year ago
Updated 14 August 2023, over 1 year ago

Describe your bug or feature request.

Creating an order with no order items causes a crash in the UI when viewing the Orders view due to no total price number.

TypeError: CommerceGuys\Intl\Formatter\CurrencyFormatter::format(): Argument #1 ($number) must be of type string, null given, called in /var/www/html/web/modules/contrib/commerce/modules/price/src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php on line 143 in CommerceGuys\Intl\Formatter\CurrencyFormatter->format() (line 93 of /var/www/html/vendor/commerceguys/intl/src/Formatter/CurrencyFormatter.php).

If a bug, provide steps to reproduce it from a clean install.

Create an order with no items, and filter the Orders view to drafts so that the order is rendered in the views table. The order total field in the view must be set to default for it to crash. The plain formatter works fine.

Maybe just check that the number is not empty on the item in the loop:

      if (empty($item->number)) {
        continue;
      }
🐛 Bug report
Status

Closed: cannot reproduce

Version

2.0

Component

Price

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024