Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_with_virtual_product_and_address.php
Go to the documentation of this file.
1 <?php
7 require __DIR__ . '/../../Customer/_files/customer.php';
8 require __DIR__ . '/../../Customer/_files/customer_address.php';
9 require __DIR__ . '/../../../Magento/Catalog/_files/product_virtual.php';
10 
13  \Magento\Quote\Model\Quote\Address::class
14 );
17  \Magento\Customer\Api\CustomerRepositoryInterface::class
18 );
21  \Magento\Customer\Api\AddressRepositoryInterface::class
22 );
23 $quoteShippingAddress->importCustomerAddressData($addressRepository->getById(1));
24 
27 $quote->setStoreId(1)
28  ->setIsActive(true)
29  ->setIsMultiShipping(false)
30  ->assignCustomerWithAddressChange($customerRepository->getById($customer->getId()))
31  ->setShippingAddress($quoteShippingAddress)
32  ->setBillingAddress($quoteShippingAddress)
33  ->setCheckoutMethod($customer->getMode())
34  ->setPasswordHash($customer->encryptPassword($customer->getPassword()))
35  ->setReservedOrderId('test_order_with_virtual_product')
36  ->setEmail('[email protected]')
37  ->addProduct($product->load($product->getId()), 1);
38 
39 $quote->collectTotals()->save();
40 
43  ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)
44  ->create();
45 $quoteIdMask->setQuoteId($quote->getId());
46 $quoteIdMask->setDataChanges(true);
47 $quoteIdMask->save();
$customer
Definition: customers.php:11
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60