/** * @param ShippingAssignmentInterface $shippingAssignment * @param CartInterface $quote * @return void * @throws InputException */ public function save(CartInterface $quote, ShippingAssignmentInterface $shippingAssignment) { /** @var \Magento\Quote\Model\Quote $quote */ foreach ($shippingAssignment->getItems() as $item) { if (!$quote->getItemById($item->getItemId())) { $this->cartItemPersister->save($quote, $item); } } $this->shippingProcessor->save($shippingAssignment->getShipping(), $quote); }
/** * @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; }