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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skyredwang created an issue. See original summary.

bojanz’s picture

Confirmed. Looks like we're missing test coverage.

The bug is in OrderTotalPrice::evaluate():

    /** @var \Drupal\commerce_price\Price $comparison_price */
    $comparison_price = $this->configuration['amount'];

$this->configuration['amount'] is just an array, we need to create a Price object here.

skyredwang’s picture

Status: Active » Needs review
FileSize
1.08 KB

How about this patch for now? In the future, we might need to consider multi-currency support?

  • bojanz committed 4108a13 on 8.x-2.x
    Issue #2833000 by skyredwang, bojanz: Price::greaterThan() must be an...
bojanz’s picture

Status: Needs review » Fixed

#3 didn't work. Made a better fix, and fixed the tests (which were broken, and hence not failing)

Thanks, skyred.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.