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]: Error while creating a new Shipping rule with particular parameters #2824

Closed
Stalex89 opened this issue May 24, 2022 · 3 comments
Closed
Assignees
Labels
bug commerce4 Issues related to Commerce v4

Comments

@Stalex89
Copy link

Stalex89 commented May 24, 2022

What happened?

Description

While creating the custom shipping method and shipping rule if you set the shipping rule "Order Total Weight" -> "Maximum" to 10000 and both "Minimum Total Shipping Cost" and "Maximum Total Shipping Cost" to 8, the following error will be thrown:

   Cannot assign string to property craft\commerce\models\ShippingRule::$maxWeight of type float in 
   /vendor/craftcms/commerce/src/controllers/ShippingRulesController.phpat line 129

Steps to reproduce

  1. Create a new Shipping method
  2. Click on a " + New shipping rule" button
  3. Inside "Conditions" tab set "Order Total Weight" maximum value to 10000
  4. Inside "Costs" tab set "Minimum Total Shipping Cost" to 8 and "Maximum Total Shipping Cost" to 8
  5. Click on Save

Expected behavior

Should create a new shipping rules with the following parameters

Actual behavior

Throws an error (see screenshot)

P.S: It seems to create a new shipping rule when you return to the shipping method page, but it also returns an error when you try to delete this shipping rule (see screenshot)

P.S.S: It seems to work fine if you set the "Order Total Weight" maximum value to lower values (for ex. 10)

Screenshots:

Screenshot 2022-05-24 at 11 14 06

170003833-c366437d-0f43-42f2-8890-6094a2e091e0

Craft CMS version

Craft Pro 4.0.3

Craft Commerce version

4.0.1

PHP version

8.1.6

Operating system and version

Darwin 21.4.0

Database type and version

MySQL 8.0.29

Image driver and version

GD 8.1.6

Installed plugins and versions

@Stalex89 Stalex89 added commerce4 Issues related to Commerce v4 bug labels May 24, 2022
@jerome2710
Copy link

I am currently experiencing this issue as well. The function Craft::$app->getFormatter()->asDecimal() will return a string, which is used to assign to properties of type float. Besides the maxWeight mentioned above, it will fail for other float types as well as $variables['shippingRule']->{$attr} loops over the properties.

@nfourtythree nfourtythree self-assigned this Jun 7, 2022
@nfourtythree
Copy link
Contributor

Hi

Thank you for reporting this issue, we have pushed up a fix for this which will be included in the next release of Commerce.

Thanks!

@Stalex89
Copy link
Author

Stalex89 commented Jun 7, 2022

Thank you for fixing!

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

3 participants