public function Order::addItem in Commerce Core 8.2
Adds an order item.
Parameters
\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item.
Return value
$this
Overrides OrderInterface::addItem
File
- modules/
order/ src/ Entity/ Order.php, line 282
Class
- Order
- Defines the order entity class.
Namespace
Drupal\commerce_order\EntityCode
public function addItem(OrderItemInterface $order_item) {
if (!$this
->hasItem($order_item)) {
$this
->get('order_items')
->appendItem($order_item);
$this
->recalculateTotalPrice();
}
return $this;
}