diff -Nuar a/vendor/magento/module-sales/Model/AdminOrder/Create.php b/vendor/magento/module-sales/Model/AdminOrder/Create.php index 1c0c4f72be2..5ebb819e1e5 100644 --- a/vendor/magento/module-sales/Model/AdminOrder/Create.php +++ b/vendor/magento/module-sales/Model/AdminOrder/Create.php @@ -736,10 +736,12 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ try { $this->_cart = $this->quoteRepository->getForCustomer($customerId, [$storeId]); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - $this->_cart->setStore($this->getSession()->getStore()); - $customerData = $this->customerRepository->getById($customerId); - $this->_cart->assignCustomer($customerData); - $this->quoteRepository->save($this->_cart); + if ($this->getQuote()->hasItems()) { + $this->_cart->setStore($this->getSession()->getStore()); + $customerData = $this->customerRepository->getById($customerId); + $this->_cart->assignCustomer($customerData); + $this->quoteRepository->save($this->_cart); + } } } @@ -776,6 +778,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ public function getCustomerGroupId() { $groupId = $this->getQuote()->getCustomerGroupId(); + // @phpstan-ignore-next-line if (!isset($groupId)) { $groupId = $this->getSession()->getCustomerGroupId(); } @@ -1435,9 +1438,10 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ */ $saveInAddressBook = (int)(!empty($address['save_in_address_book'])); $shippingAddress->setData('save_in_address_book', $saveInAddressBook); - } - if ($address instanceof \Magento\Quote\Model\Quote\Address) { + } elseif ($address instanceof \Magento\Quote\Model\Quote\Address) { $shippingAddress = $address; + } else { + $shippingAddress = null; } $this->setRecollect(true);