Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_with_fpt.php
Go to the documentation of this file.
1 <?php
13 
14 require __DIR__ . '/../../Weee/_files/product_with_fpt.php';
15 
17 $objectManager = Bootstrap::getObjectManager();
18 
20  'firstname' => 'John',
21  'lastname' => 'Doe',
22  'company' => '',
23  'email' => '[email protected]',
24  'street' => [
25  0 => 'test1',
26  ],
27  'city' => 'Test',
28  'region_id' => '1',
29  'region' => '',
30  'postcode' => '9001',
31  'country_id' => 'US',
32  'telephone' => '11111111',
33 ];
35 $billingAddress = $objectManager->create(Address::class, ['data' => $addressData]);
36 $billingAddress->setAddressType('billing');
37 
39 $shippingAddress->setAddressType('shipping')
40  ->setId(null);
41 
43 $quote = $objectManager->create(Quote::class);
44 $quote->setCustomerIsGuest(true)
45  ->setReservedOrderId('100000016')
46  ->setBillingAddress($billingAddress)
47  ->setShippingAddress($shippingAddress);
48 
49 $quote->addProduct($product, 1);
50 $quote->collectTotals();
51 
53 $quoteRepository = $objectManager->get(QuoteRepository::class);
$quote
$billingAddress
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
$objectManager
$addressData
$shippingAddress
$quoteRepository