Problem/Motivation

We are using the stock module, and we want to be able to restrict adding of some products to the cart. We can just override the controller and copy-paste everything, but I don't like it.

Another thing is that we are using commerce_vado module. It adds a lot of complexity. It extensively uses data field in order_items. Hence we need to somehow clean up the order item cloning. It could be done in ORDER_CLONED, but as for me, it should be triggered only once and not in the loop.

Proposed resolution

Add two more events to be able to react on order item cloning and order item availability check.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dinazaur created an issue. See original summary.

dinazaur’s picture

Assigned: dinazaur » Unassigned
Status: Active » Needs review
seanr’s picture

Category: Task » Feature request
Status: Needs review » Needs work

This patch causes a fatal error on 2.4 in Drupal 10:

TypeError: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch(): Argument #1 ($event) must be of type object, string given, called in /var/www/html/web/modules/contrib/commerce_repeat_order/src/Controller/CommerceRepeatOrder.php on line 125 in Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (line 89 of core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php).

Drupal\commerce_repeat_order\Controller\CommerceRepeatOrder->repeatOrder(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
seanr’s picture

Status: Needs work » Needs review

Dispatcher argument order switched at some point. Latest commit to the MR fixes.

neilnz’s picture

Status: Needs review » Reviewed & tested by the community

LGTM. Solved our product availability situation, and is backwards compatible.