You are here

public function XquantityStockOrderEventSubscriber::onOrderItemUpdate in Commerce Extended Quantity 8

Performs a stock transaction on an order item update.

Parameters

\Drupal\commerce_order\Event\OrderItemEvent $event: The order item event.

File

modules/xquantity_stock/src/EventSubscriber/XquantityStockOrderEventSubscriber.php, line 108

Class

XquantityStockOrderEventSubscriber
Commerce order event subscriber.

Namespace

Drupal\xquantity_stock\EventSubscriber

Code

public function onOrderItemUpdate(OrderItemEvent $event) {

  // Prevent on the Add to cart and Shopping cart update forms.
  if ($this->routeMatch
    ->getParameter('commerce_order')) {
    if (($order_item = $event
      ->getOrderItem()) && ($order = $order_item
      ->getOrder())) {
      $this
        ->updateStock($order, $order_item);
    }
  }
}