You are here

public function Order::removeItem in Commerce Core 8.2

Removes an order item.

Parameters

\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item.

Return value

$this

Overrides OrderInterface::removeItem

File

modules/order/src/Entity/Order.php, line 293

Class

Order
Defines the order entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function removeItem(OrderItemInterface $order_item) {
  $index = $this
    ->getItemIndex($order_item);
  if ($index !== FALSE) {
    $this
      ->get('order_items')
      ->offsetUnset($index);
    $this
      ->recalculateTotalPrice();
  }
  return $this;
}