Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
shipping_address_list.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
12 
17 if (empty($quote)) {
18  throw new \Exception('$quote should be defined in the parent fixture');
19 }
20 
22  [
23  'firstname' => 'Jonh',
24  'lastname' => 'Doe',
25  'telephone' => '0333-233-221',
26  'street' => ['Main Division 1'],
27  'city' => 'Culver City',
28  'region' => 'CA',
29  'postcode' => 90800,
30  'country_id' => 'US',
31  'email' => '[email protected]',
32  'address_type' => 'shipping',
33  ],
34  [
35  'firstname' => 'Antoni',
36  'lastname' => 'Holmes',
37  'telephone' => '0333-233-221',
38  'street' => ['Second Division 2'],
39  'city' => 'Denver',
40  'region' => 'CO',
41  'postcode' => 80203,
42  'country_id' => 'US',
43  'email' => '[email protected]',
44  'address_type' => 'shipping'
45  ]
46 ];
47 
49 $objectManager = Bootstrap::getObjectManager();
50 
51 $methodCode = 'flatrate_flatrate';
52 foreach ($addressList as $data) {
54  $rate = $objectManager->create(Rate::class);
55  $rate->setCode($methodCode)
56  ->setPrice(5.00);
57 
58  $address = $objectManager->create(AddressInterface::class, ['data' => $data]);
59  $address->setShippingMethod($methodCode)
60  ->addShippingRate($rate)
61  ->setShippingAmount(5.00)
62  ->setBaseShippingAmount(5.00);
63 
64  $quote->addAddress($address);
65 }
66 $quote->setIsMultiShipping(1);
$quote
$address
Definition: customer.php:38
if(empty($quote)) $addressList