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

TypeError attempting to save new product without price #58

Closed
mattstein opened this issue Nov 24, 2020 · 1 comment · Fixed by #59
Closed

TypeError attempting to save new product without price #58

mattstein opened this issue Nov 24, 2020 · 1 comment · Fixed by #59
Labels

Comments

@mattstein
Copy link

Description

When attempting to save a new product without entering its price, a type error is returned instead of the validation error I’d expect:

TypeError
Return value of craft\digitalproducts\elements\Product::getPrice() must be of the type float, string returned

Looks like it needs to be cast as a float for MySQL or that a null value needs to be accounted for.

Steps to reproduce

  1. Install Craft with Craft Commerce + Digital Products plugins and create a Product Type.
  2. Choose Digital ProductsProducts+ New Product.
  3. Enter some garbage input, specifically leaving Price empty, and choose Save.
  4. Observe the resulting type error.
  5. Go back and add a numeric value for Price, then choose Save.
  6. Observe the element detail view (as expected) where the empty SKU has a validation error (“Sku cannot be blank.”) as expected.
  7. Add the SKU and save, just for good feels and a sense of completion.

Additional info

  • Craft version: 3.5.15.1
  • PHP version: 7.3.20, 7.4.8
  • Database driver & version: MySQL 5.5.5
  • Plugins & versions: Digital Products 2.4.1, Commerce 3.2.10.1
mattstein pushed a commit that referenced this issue Nov 24, 2020
@mattstein
Copy link
Author

^ Tested + submitted a stunning PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant