Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I created an promotion just for testing, and immediately get this error, when I go to /admin/commerce/orders page:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\commerce_price\Price::greaterThan() must be an instance of Drupal\commerce_price\Price, array given, called in /var/www/html/modules/commerce/modules/promotion/src/Plugin/Commerce/PromotionCondition/OrderTotalPrice.php on line 70 in Drupal\commerce_price\Price->greaterThan() (line 203 of modules/commerce/modules/price/src/Price.php).
Drupal\commerce_price\Price->greaterThan(Array) (Line: 70)
Drupal\commerce_promotion\Plugin\Commerce\PromotionCondition\OrderTotalPrice->evaluate() (Line: 262)
Drupal\commerce_promotion\Entity\Promotion->applies(Object) (Line: 46)
Drupal\commerce_promotion\PromotionOrderProcessor->process(Object) (Line: 152)
Drupal\commerce_order\OrderRefresh->refresh(Object) (Line: 92)
Drupal\commerce_order\OrderStorage->doPreSave(Object) (Line: 389)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 761)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 364)
Drupal\Core\Entity\Entity->save() (Line: 113)
Drupal\commerce_order\OrderStorage->postLoad(Array) (Line: 249)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 1555)
Drupal\views\Plugin\views\query\Sql->loadEntities(Array) (Line: 1480)
Drupal\views\Plugin\views\query\Sql->execute(Object) (Line: 1413)
Drupal\views\ViewExecutable->execute(NULL) (Line: 1441)
Drupal\views\ViewExecutable->render() (Line: 171)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1617)
Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 78)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array) (Line: 376)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
The promotion I created is attached:
Comment | File | Size | Author |
---|---|---|---|
#3 | price_greaterthan-2833000-3.patch | 1.08 KB | skyredwang |
Edit 20 Off OC.png | 68.9 KB | skyredwang |
Comments
Comment #2
bojanz CreditAttribution: bojanz commentedConfirmed. Looks like we're missing test coverage.
The bug is in OrderTotalPrice::evaluate():
$this->configuration['amount'] is just an array, we need to create a Price object here.
Comment #3
skyredwangHow about this patch for now? In the future, we might need to consider multi-currency support?
Comment #5
bojanz CreditAttribution: bojanz commented#3 didn't work. Made a better fix, and fixed the tests (which were broken, and hence not failing)
Thanks, skyred.