verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

Unknown Property ShippingMethodOption Error #27

Closed codewithkyle closed 4 years ago

codewithkyle commented 4 years ago

Description

After updating to Commerce 3.1.1 users can no longer complete the checkout process. The following error is received when adding a product to the cart or navigating to the shipping page during checkout.

"Setting unknown property: craft\commerce\models\ShippingMethodOption::provider"

Steps to reproduce

  1. Log in
  2. Add product to cart (receives error)
  3. Navigate to checkout
  4. Navigate to Shipping page (same error)

Additional info

Stack Trace

2020-04-10 12:08:06 [-][20437][-][error][yii\base\UnknownPropertyException] yii\base\UnknownPropertyException: Setting unknown property: craft\commerce\models\ShippingMethodOption::provider in /media/sf_Sites/website/vendor/yiisoft/yii2/base/Component.php:209
Stack trace:
#0 /media/sf_Sites/website/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('provider', Object(verbb\postie\providers\UPS))
#1 /media/sf_Sites/website/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\commerce\models\ShippingMethodOption), Array)
#2 /media/sf_Sites/website/vendor/craftcms/commerce/src/elements/Order.php(1574): yii\base\BaseObject->__construct(Array)
#3 /media/sf_Sites/website/vendor/yiisoft/yii2/base/Component.php(139): craft\commerce\elements\Order->getAvailableShippingMethodOptions()
#4 /media/sf_Sites/website/vendor/craftcms/cms/src/base/Element.php(1102): yii\base\Component->__get('availableShippi...')
#5 /media/sf_Sites/website/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): craft\base\Element->__get('availableShippi...')
#6 /media/sf_Sites/website/vendor/craftcms/commerce/src/controllers/BaseFrontEndController.php(66): yii\base\Model->toArray(Array, Array)
#7 /media/sf_Sites/website/vendor/craftcms/commerce/src/controllers/CartController.php(367): craft\commerce\controllers\BaseFrontEndController->cartArray(Object(craft\commerce\elements\Order))
#8 /media/sf_Sites/website/vendor/craftcms/commerce/src/controllers/CartController.php(246): craft\commerce\controllers\CartController->_returnCart()
#9 [internal function]: craft\commerce\controllers\CartController->actionUpdateCart()
#10 /media/sf_Sites/website/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /media/sf_Sites/website/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#12 /media/sf_Sites/website/vendor/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('update-cart', Array)
#13 /media/sf_Sites/website/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('update-cart', Array)
#14 /media/sf_Sites/website/vendor/craftcms/cms/src/web/Application.php(291): yii\base\Module->runAction('commerce/cart/u...', Array)
#15 /media/sf_Sites/website/vendor/craftcms/cms/src/web/Application.php(559): craft\web\Application->runAction('commerce/cart/u...', Array)
#16 /media/sf_Sites/website/vendor/craftcms/cms/src/web/Application.php(270): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#17 /media/sf_Sites/website/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /media/sf_Sites/website/public/index.php(21): yii\base\Application->run()
#19 {main}
keyurshah commented 4 years ago

I am having the same exact error as well. Not sure what has changed to cause this.

Thanks!

engram-design commented 4 years ago

Looking into this shortly. What providers are you using out of interest? Seems like something has changed in 3.1.x

keyurshah commented 4 years ago

I'm using a custom provider through postie

i created an issue in craft/commerce as well referenced above. It seems that new code was added in the json response.

Also, for me, this seems to occur only when logged in or a customer/user is set on the cart.

codewithkyle commented 4 years ago

I am only using UPS

engram-design commented 4 years ago

Hmmm, I can't seem to replicate this with the default templates, or any of the enabled providers, so will continue testing.

EDIT: Looks like I need to call cart.getAvailableShippingMethodOptions() which throws this.

engram-design commented 4 years ago

I'll try and reach out to the Commerce team about this, and what the preferred solution is. I can't think of anything immediately on Postie's end that wouldn't be a larger refactor. See https://github.com/craftcms/commerce/issues/1378#issuecomment-613152838

keyurshah commented 4 years ago

thanks for looking into this. that was a sneaky error. after this is resolved, if we can discuss good ways to test for this to prevent in the future.

engram-design commented 4 years ago

Fixed in https://github.com/craftcms/commerce/issues/1378