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

Unable to add Custom Line Items to Completed Orders #145

Open
apitel opened this issue Oct 11, 2024 · 1 comment
Open

Unable to add Custom Line Items to Completed Orders #145

apitel opened this issue Oct 11, 2024 · 1 comment

Comments

@apitel
Copy link

apitel commented Oct 11, 2024

Describe the bug

Craft Commerce introduced a feature allowing custom line items to be created on the fly from the control panel.

When clicking "+ Add a custom line item" the order gets stuck while being recalculated.

In the network tab can be seen 500 error being throw:

2024-10-11 11:54:34 [web.ERROR] [yii\base\InvalidConfigException] yii\base\InvalidConfigException: Cannot get a purchasable for a custom line item in /var/www/html/vendor/craftcms/commerce/src/models/LineItem.php:821
Stack trace:

#0 /var/www/html/vendor/yiisoft/yii2/base/Component.php(139): craft\commerce\models\LineItem->getPurchasable()

#1 /var/www/html/vendor/verbb/postie/src/helpers/PostieHelper.php(99): yii\base\Component->__get('purchasable')

#2 /var/www/html/vendor/verbb/postie/src/base/Provider.php(707): verbb\postie\helpers\PostieHelper::getOrderLineItems(Object(craft\commerce\elements\Order))

#3 /var/www/html/vendor/verbb/postie/src/base/Provider.php(311): verbb\postie\base\Provider->packOrder(Object(craft\commerce\elements\Order), Array)

#4 /var/www/html/vendor/verbb/postie/src/services/Service.php(93): verbb\postie\base\Provider->prepareForShippy(Object(verbb\shippy\models\Shipment), Object(craft\commerce\elements\Order))

#5 /var/www/html/vendor/verbb/postie/src/services/Service.php(179): verbb\postie\services\Service->getShippingMethodsForOrder(Object(craft\commerce\elements\Order))

#6 [internal function]: verbb\postie\services\Service->registerShippingMethods(Object(craft\commerce\events\RegisterAvailableShippingMethodsEvent))

#7 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(craft\commerce\events\RegisterAvailableShippingMethodsEvent))

#8 /var/www/html/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger('craft\\commerce\...', 'registerAvailab...', Object(craft\commerce\events\RegisterAvailableShippingMethodsEvent))

#9 /var/www/html/vendor/craftcms/commerce/src/services/ShippingMethods.php(131): yii\base\Component->trigger('registerAvailab...', Object(craft\commerce\events\RegisterAvailableShippingMethodsEvent))

#10 /var/www/html/vendor/craftcms/commerce/src/elements/Order.php(2125): craft\commerce\services\ShippingMethods->getMatchingShippingMethods(Object(craft\commerce\elements\Order))

#11 /var/www/html/vendor/yiisoft/yii2/base/Component.php(139): craft\commerce\elements\Order->getAvailableShippingMethodOptions()

#12 /var/www/html/vendor/craftcms/cms/src/base/Element.php(2337): yii\base\Component->__get('availableShippi...')

#13 /var/www/html/vendor/yiisoft/yii2/base/ArrayableTrait.php(126): craft\base\Element->__get('availableShippi...')

#14 /var/www/html/vendor/craftcms/cms/src/base/Element.php(2493): craft\base\Element->traitToArray(Array, Array, true)

#15 /var/www/html/vendor/craftcms/commerce/src/controllers/OrdersController.php(624): craft\base\Element->toArray(Array, Array)

#16 /var/www/html/vendor/craftcms/commerce/src/controllers/OrdersController.php(476): craft\commerce\controllers\OrdersController->_orderToArray(Object(craft\commerce\elements\Order))

#17 [internal function]: craft\commerce\controllers\OrdersController->actionRefresh()

#18 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

#19 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)

#20 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('refresh', Array)

#21 /var/www/html/vendor/craftcms/cms/src/web/Application.php(350): yii\base\Module->runAction('commerce/orders...', Array)

#22 /var/www/html/vendor/craftcms/cms/src/web/Application.php(649): craft\web\Application->runAction('commerce/orders...', Array)

#23 /var/www/html/vendor/craftcms/cms/src/web/Application.php(312): craft\web\Application->_processActionRequest(Object(craft\web\Request))

#24 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))

#25 /var/www/html/public/index.php(12): yii\base\Application->run()

#26 {main} {"memory":35209264,"exception":"[object] (yii\\base\\InvalidConfigException(code: 0): Cannot get a purchasable for a custom line item at /var/www/html/vendor/craftcms/commerce/src/models/LineItem.php:821)"}

Steps to reproduce

  1. Go to Commerce control panel
  2. Create a new order and mark as complete
  3. Edit order and Click Add a custom line item

image

Craft CMS version

Craft Pro 5.4.6

Plugin version

dev-craft-5

Multi-site?

Yes

Additional context

No response

@apitel apitel changed the title Unable to complete orders with Custom Line Items Unable to add Custom Line Items to Completed Orders Oct 11, 2024
@engram-design
Copy link
Member

Fixed for the next release. To get this early, run composer require verbb/postie:"dev-craft-5 as 5.0.6".

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

No branches or pull requests

2 participants