craftcms/commerce

[5.x]: Weight is rounded when decimal separator is a comma

Closed this issue · 2 comments

What happened?

Description

When a user sets the language to Dutch all numbers get a comma for a decimal separator.
Editing the weight field in a product variant with a comma rounds the number.
For example 31,11 becomes 31.
In English this is not a problem when using a point as decimal separator.

There is a workaround in Dutch by using a point. When saving the variant with a weight of 31.11 and opening it again will show a weight of 31,11. So the conversion works but it just does not accept it initially.

Steps to reproduce

  1. Set language to Dutch
  2. Change the weight of a product variant to 31,11 g

Expected behavior

31,11 g should stay 31,11 after saving.

Actual behavior

It rounds a value like 31,11 to 31.

Craft CMS version

5.3.4

Craft Commerce version

5.0.16.2

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Thanks for reporting this. I have fixed it for the next release.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#5c292c1eb3ee25a8bad168f12007c73ea471ae8b as 5.0.16.2",
  "...": "..."
}

Then run composer update.

We will update this ticket once the release is out.