public function CartManager::createOrderItem in Commerce Core 8.2
Creates an order item for the given purchasable entity.
Parameters
\Drupal\commerce\PurchasableEntityInterface $entity: The purchasable entity.
string $quantity: The quantity.
Return value
\Drupal\commerce_order\Entity\OrderItemInterface The created order item. Unsaved.
Overrides CartManagerInterface::createOrderItem
1 call to CartManager::createOrderItem()
- CartManager::addEntity in modules/
cart/ src/ CartManager.php - Adds the given purchasable entity to the given cart order.
File
- modules/
cart/ src/ CartManager.php, line 92
Class
- CartManager
- Default implementation of the cart manager.
Namespace
Drupal\commerce_cartCode
public function createOrderItem(PurchasableEntityInterface $entity, $quantity = '1') {
$order_item = $this->orderItemStorage
->createFromPurchasableEntity($entity, [
'quantity' => $quantity,
]);
return $order_item;
}