Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Text inputs in Discount Conditions/Actions cause a WSOD/GSOD (Internal Server Error) #3067

Closed
robzor opened this issue Jan 23, 2023 · 2 comments
Assignees
Labels
bug commerce4 Issues related to Commerce v4

Comments

@robzor
Copy link

robzor commented 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:

  • 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

  1. Go to Promotions > Discounts > [Any Discount] > Conditions.
  2. Enter £100 in Purchase Total
  3. 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

@robzor robzor added commerce4 Issues related to Commerce v4 bug labels Jan 23, 2023
@robzor 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
nfourtythree added a commit that referenced this issue Feb 1, 2023
…ormalization

Fixes #3067 number normalization on discount inputs
@nfourtythree
Copy link
Contributor

Hi @robzor

Thank you for bringing this to our attention.

We have pushed some updates that will help with the number normalisation on the discounts edit page.

Thanks!

@robzor
Copy link
Author

robzor commented Feb 1, 2023

@nfourtythree thanks for fixing it! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4
Projects
None yet
Development

No branches or pull requests

4 participants