Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Service/Order/Quote/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteFactory;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Quote\Api\CartRepositoryInterface;

/**
* Create quote (guest or customer)
Expand All @@ -37,6 +38,11 @@ class Create
*/
private $addressHandler;

/**
* @var CartRepositoryInterface
*/
private $cartRepository;

/**
* QuoteCreation constructor.
*
Expand All @@ -47,11 +53,13 @@ class Create
public function __construct(
QuoteFactory $quoteFactory,
CustomerHandler $customerHandler,
AddressHandler $addressHandler
AddressHandler $addressHandler,
CartRepositoryInterface $cartRepository
) {
$this->quoteFactory = $quoteFactory;
$this->customerHandler = $customerHandler;
$this->addressHandler = $addressHandler;
$this->cartRepository = $cartRepository;
}

/**
Expand Down Expand Up @@ -82,6 +90,10 @@ public function createCustomerQuote(array $orderData, StoreInterface $store): Qu
$quote->setTransactionFee($orderData['price']['transaction_fee']);
}

return $quote->save();
// Make sure the cart is registered by the repository
$this->cartRepository->save($quote);
$quote = $this->cartRepository->get($quote->getId());

return $quote;
}
}