Problem/Motivation
It seems like when we were preparing for D9 we lost a few improvements made along the way. One was validation for non-numeric and empty values. The other is the inclusion of the price token in the error message displayed when an invalid amount is entered.
Non-Numeric Validation
When I enter a string with non numeric characters like "A1" or simply leave the field blank "" and press "Add to Cart" an uncaught exception is produced. Here are the errors:
InvalidArgumentException: The provided value "" is not a numeric value. in Drupal\commerce_price\Calculator::assertNumberFormat() (line 261 of /var/www/html/web/modules/contrib/commerce/modules/price/src/Calculator.php).
InvalidArgumentException: The provided value "dad" is not a numeric value. in Drupal\commerce_price\Calculator::assertNumberFormat() (line 261 of /var/www/html/web/modules/contrib/commerce/modules/price/src/Calculator.php).
This was originally addressed in this issue (#3075504).
Make validation message include @price token
It is a benefit for developers to be able to use the @price token when performing string overrides to change the validation message we produce when a price is below the minimum amount.
We addressed this in issue #3077250, but lost it along the way.
Steps to reproduce
Both bugs:
Create a clean D9 installation. Install Commerce ^2.28 via stock instructions. Install the commerce_choose_price 8.x-1.x widget.
Enable commerce, commerce_order, commerce_product, commerce_cart, commerce_checkout, commece_product and commerce_choose_price.
Configure the default product and order item type to use the choose price widget.
Non-Numeric Validation
Visit the product and enter a non-numeric or blank value. Press "Add to Cart".
Make validation message include @price token
Attempt to include the price in a string override of our current message "The chosen price is too low".
Proposed resolution
Return these two fixes that were dropped.
Issue fork commerce_choose_price-3255026
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lkacenjaBroadening scope of ticket to include a couple things we lost along the way.
Comment #5
gregglesIn my opinion this is "RTBC" since these changes were already committed and they were removed without a reason, which seems like a mistake.
Comment #6
cyu commentedI'm using this patch now and both of those fixes work well for me. Thanks.
Comment #8
gregglesThanks for that confirmation and your ongoing help with the module, cYu. I've merged this now and will make a new release.