-
Notifications
You must be signed in to change notification settings - Fork 170
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
[3.x]: Object of class <shipping method> could not be converted to int when calling getAvailableShippingMethodOptions
#3093
Comments
@OscarBarrett, I can’t seem to replicate the issue. It appears to be an issue on how the custom shipping got registered. Have you contacted the third party developer about the issue? |
Hey, @pdaleramirez I'm a colleague of @OscarBarrett just for context.
Doing $option->matchesOrder = ArrayHelper::isIn($method->getHandle(), $availableMethods); ends up working as within Take a look at this use craft\commerce\models\ShippingMethod;
$shippingMethod = new ShippingMethod();
$shippingMethod->handle = 76;
$shippingMethod->name = "Test";
$shippingMethod->enabled = true;
$allShippingMethods = [];
$allShippingMethods[$shippingMethod->handle] = $shippingMethod;
print(in_array('76', $allShippingMethods)); // doesn't throw error
print(in_array(76, $allShippingMethods)); // throws error: could not be converted to int You can see this in the Sentry stack trace: It seems to be similar to the SO case linked in the description, where they somehow got an int handle. #2 /var/www/sslptest.com/vendor/yiisoft/yii2/helpers/BaseArrayHelper.php(853): in_array(349, Array, false) Additional we could make an issue to verbb/postie, however it wouldn't solve the problem of creating a shippingMethod with int as a handle. |
@zollf, The shipping method handle, should not be an integer, but I’ve added a fix for this issue. It forces the shipping handle to return as a string when the handle is numeric. |
@pdaleramirez I can confirm that we've run into the same issue. Do you know when you'll have a release with that fix? |
To get the fix early, change your "require": {
"craftcms/commerce": "v3.x-dev#c9cdda166dcbaecaaee6e0ac13e9a0aa7f0f8b6c",
"...": "..."
} Then run |
@pdaleramirez I'm the poster from the related SO post. Just tried this fix using this version, ran into an error that resolves when we move back to the published version:
|
@joshparylak Your issue seems unrelated; it comes from a custom module. |
@pdaleramirez Looks like we actually had to scale up to php 8 to clear this error, which would be a no-go at the moment for production for us. Clearing that error has run us into a number of other errors, and we've been yet unable to get the site running stably on this branch. What's the timeline for an official release version of this potential fix look like? |
This PHP error has been fixed and is the 3.4.20.1 release. Thanks. |
What happened?
Description
When calling
$order->getAvailableShippingMethodOptions()
on abeforeSave
event, we're getting an exception here.commerce/src/elements/Order.php
Line 1899 in 53f4e11
In our case we're running into this with an object of class verbb\postie\models\ShippingMethod.
Related to #2986 and 6bf9ebd
Related Stack Exchange post: https://craftcms.stackexchange.com/questions/40448/object-of-class-craft-commerce-models-shippingmethod-could-not-be-converted-to-i
Stack trace:
Further context:
Steps to reproduce
$order->getAvailableShippingMethodOptions()
Craft CMS version
3.7.63.1
Craft Commerce version
3.4.19
PHP version
7.4.33
Operating system and version
Alpine, latest
Database type and version
MySQL 5.7
Image driver and version
N/A
Installed plugins and versions
The text was updated successfully, but these errors were encountered: