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
In a Discount, if you add a string in some of the fields under Conditions it causes a Grey Screen Of Death with 'Internal Server Error' (or a WSOD if you are in Devmode). Here is an example of the error:
TypeError: Cannot assign string to property craft\commerce\models\Discount::$purchaseTotal of type float at /var/www/html/vendor/craftcms/commerce/src/controllers/DiscountsController.php:163
For some reason some of the fields are input type="number" and some are not. The fields that are not:
Purchase Total
Per User Discount Limit
Per Email Address Discount Limit
Total Discount Use Limit
Ironically, they even have a min="0" attribute on them even though they are not number input fields.
I can see that:
Per Item Amount Off
Per Item Percentage Off
Flat Order Discount Amount Off
Also are input type="text"
I would suggest that there you either/or change these to input type numbers or at least show some validation that a user has entered in something incorrect instead of the error "Internal Server Error"
Steps to reproduce
Go to Promotions > Discounts > [Any Discount] > Conditions.
Enter £100 in Purchase Total
Click 'save'
Expected behavior
In browser or inpage validation to show you that "£100" is not valid and that the user value needs to be a number, not a string/float.
Actual behavior
Grey screen of death 'Internal Server Error' with no indication of what the error was.
Craft CMS version
4.3.6.1
Craft Commerce version
4.2.4
PHP version
8.0.25
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered:
robzor
changed the title
[4.x]: Text inputs in Discount conditions cause a WSOD/GSOD
[4.x]: Text inputs in Discount Conditions/Actions cause a WSOD/GSOD (Internal Server Error)
Jan 23, 2023
What happened?
Description
In a Discount, if you add a string in some of the fields under Conditions it causes a Grey Screen Of Death with 'Internal Server Error' (or a WSOD if you are in Devmode). Here is an example of the error:
TypeError: Cannot assign string to property craft\commerce\models\Discount::$purchaseTotal of type float at /var/www/html/vendor/craftcms/commerce/src/controllers/DiscountsController.php:163
For some reason some of the fields are input type="number" and some are not. The fields that are not:
Ironically, they even have a min="0" attribute on them even though they are not number input fields.
I can see that:
Also are input type="text"
I would suggest that there you either/or change these to input type numbers or at least show some validation that a user has entered in something incorrect instead of the error "Internal Server Error"
Steps to reproduce
Expected behavior
In browser or inpage validation to show you that "£100" is not valid and that the user value needs to be a number, not a string/float.
Actual behavior
Grey screen of death 'Internal Server Error' with no indication of what the error was.
Craft CMS version
4.3.6.1
Craft Commerce version
4.2.4
PHP version
8.0.25
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: