public function CartManager::updateOrderItem in Commerce Core 8.2
Updates the given order item.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $cart: The cart order.
\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item.
bool $save_cart: Whether the cart should be saved after the operation.
Overrides CartManagerInterface::updateOrderItem
File
- modules/
cart/ src/ CartManager.php, line 141
Class
- CartManager
- Default implementation of the cart manager.
Namespace
Drupal\commerce_cartCode
public function updateOrderItem(OrderInterface $cart, OrderItemInterface $order_item, $save_cart = TRUE) {
/** @var \Drupal\commerce_order\Entity\OrderItemInterface $original_order_item */
$original_order_item = $this->orderItemStorage
->loadUnchanged($order_item
->id());
$order_item
->save();
$event = new CartOrderItemUpdateEvent($cart, $order_item, $original_order_item);
$this->eventDispatcher
->dispatch(CartEvents::CART_ORDER_ITEM_UPDATE, $event);
$this
->resetCheckoutStep($cart);
if ($save_cart) {
$cart
->save();
}
}