/** * @param CartInterface $quote * @return \Magento\Quote\Api\Data\ShippingAssignmentInterface */ public function create(CartInterface $quote) { /** @var \Magento\Quote\Model\Quote $quote */ $shippingAddress = $quote->getShippingAddress(); /** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment */ $shippingAssignment = $this->shippingAssignmentFactory->create(); $shippingAssignment->setItems($quote->getItems()); $shippingAssignment->setShipping($this->shippingProcessor->create($shippingAddress)); return $shippingAssignment; }
/** * @param CartInterface $quote * @return CartInterface * * @throws InputException * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\LocalizedException * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function save(CartInterface $quote) { /** @var \Magento\Quote\Model\Quote $quote */ // Quote Item processing $items = $quote->getItems(); if ($items) { foreach ($items as $item) { /** @var \Magento\Quote\Model\Quote\Item $item */ if (!$item->isDeleted()) { $quote->setLastAddedItem($this->cartItemPersister->save($quote, $item)); } } } // Billing Address processing $billingAddress = $quote->getBillingAddress(); if ($billingAddress) { $this->billingAddressPersister->save($quote, $billingAddress); } $this->processShippingAssignment($quote); $this->quoteResourceModel->save($quote->collectTotals()); return $quote; }
/** * Returns list of line items in the cart * * @return \Magento\Quote\Api\Data\CartItemInterface[]|null */ public function getItems() { return $this->quote->getItems(); }