private function initializeCustomer() { if ($this->proxyOrder->isCheckoutMethodGuest()) { $this->quote->setCustomerId(null)->setCustomerEmail($this->proxyOrder->getBuyerEmail())->setCustomerFirstname($this->proxyOrder->getCustomerFirstName())->setCustomerLastname($this->proxyOrder->getCustomerLastName())->setCustomerIsGuest(true)->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID); } $this->quote->assignCustomer($this->proxyOrder->getCustomer()); }
/** * @magentoAppIsolation enabled * @magentoDbIsolation enabled * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php */ public function testSaveShippingWithCustomerId() { $this->_currentQuote->setCustomerId(1)->save(); $data = ['address_id' => '', 'firstname' => 'Joe', 'lastname' => 'Black', 'company' => 'Lunatis', 'street' => ['1100 Parmer', 'ln.'], 'city' => 'Austin', 'region_id' => '57', 'region' => '', 'postcode' => '78757', 'country_id' => 'US', 'telephone' => '(512) 999-9999', 'fax' => '', 'save_in_address_book' => 1]; $this->_model->saveShipping($data, 1); $address = $this->_currentQuote->getShippingAddress(); /* Verify that data from Customer Address identified by id=1 is set */ $this->assertEquals('John', $address->getFirstname()); $this->assertEquals('Smith', $address->getLastname()); $this->assertEquals(['Green str, 67'], $address->getStreet()); $this->assertEquals('CityM', $address->getCity()); $this->assertEquals('Alabama', $address->getRegion()); $this->assertEquals(1, $address->getRegionId()); $this->assertEquals('75477', $address->getPostcode()); $this->assertEquals('US', $address->getCountryId()); $this->assertEquals('3468676', $address->getTelephone()); $this->assertEquals('*****@*****.**', $address->getEmail()); $this->assertTrue($address->getCollectShippingRates()); $this->assertEquals(1, $address->getCustomerAddressId()); }
/** * Prepare quote for guest checkout order submit * * @param Quote $quote * @return void */ private function prepareGuestQuote(Quote $quote) { $quote->setCustomerId(null)->setCustomerEmail($quote->getBillingAddress()->getEmail())->setCustomerIsGuest(true)->setCustomerGroupId(Group::NOT_LOGGED_IN_ID); }