You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding or editing an adjustment, either on a LineItem or the full order, there's several issues related to input in the 'amount' field. You get errors if you leave the field empty or if Craft evaluates the field as a string. There's sometimes valid reasons to start typing a "string", such as negative numbers.
This is the error I usually get: "Cannot assign string to property craft\commerce\models\OrderAdjustment::$amount of type float at /var/www/html/vendor/craftcms/commerce/src/controllers/OrdersController.php:1442", the line can also be 1470.
Steps to reproduce
View any order
Click 'edit' on a LineItem or 'Edit adjustments' at the bottom on the Order.
Add an adjustment
Delete the default "0" and delay typing the amount you want for 1-2 seconds.
'Internal Server Error' error and most of the order screen turns grey and unresponsive.
Basically any situation where the first value in the amount field isn't numerical (or "-" + a number), an error is thrown. This causes issues if users are slow typers. Example: They want to type "-100" in the amount field, start with "-" and are a bit slow to hit the 1 key. The order recalculates with just "-" in the amount field for an adjustment. An error is thrown because it expects a float and got a string. The user is confused because they weren't even done typing and there's no meaningful error message.
Expected behavior
More graceful handling of these errors. Maybe just reset the field to 0 on invalid input.
Alternatively, throttle the recalculate/update more than 1-2 seconds after input change, so slow typers have a chance to finish typing what they want to before the order recalculates.
Actual behavior
'Internal Server Error' and grey screens.
Craft CMS version
Craft Pro 4.5.11.1
Craft Commerce version
4.3.2
PHP version
8.1.26
Operating system and version
Linux 6.1.0-0.deb11.11-amd64
Database type and version
MariaDB 10.11.5
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered:
What happened?
Description
This issue is somewhat similar to #3067
When adding or editing an adjustment, either on a LineItem or the full order, there's several issues related to input in the 'amount' field. You get errors if you leave the field empty or if Craft evaluates the field as a string. There's sometimes valid reasons to start typing a "string", such as negative numbers.
This is the error I usually get: "Cannot assign string to property craft\commerce\models\OrderAdjustment::$amount of type float at /var/www/html/vendor/craftcms/commerce/src/controllers/OrdersController.php:1442", the line can also be 1470.
Steps to reproduce
Basically any situation where the first value in the amount field isn't numerical (or "-" + a number), an error is thrown. This causes issues if users are slow typers. Example: They want to type "-100" in the amount field, start with "-" and are a bit slow to hit the 1 key. The order recalculates with just "-" in the amount field for an adjustment. An error is thrown because it expects a float and got a string. The user is confused because they weren't even done typing and there's no meaningful error message.
Expected behavior
More graceful handling of these errors. Maybe just reset the field to 0 on invalid input.
Alternatively, throttle the recalculate/update more than 1-2 seconds after input change, so slow typers have a chance to finish typing what they want to before the order recalculates.
Actual behavior
'Internal Server Error' and grey screens.
Craft CMS version
Craft Pro 4.5.11.1
Craft Commerce version
4.3.2
PHP version
8.1.26
Operating system and version
Linux 6.1.0-0.deb11.11-amd64
Database type and version
MariaDB 10.11.5
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: