Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_sec_website.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
16 
22 require __DIR__ . '/../../Customer/Fixtures/customer_sec_website.php';
23 require __DIR__ . '/simple_product.php';
24 
26 $objectManager = Bootstrap::getObjectManager();
27 
28 $addressData = include __DIR__ . '/../../Customer/Fixtures/address_data.php';
30 $shippingAddress = $objectManager->create(Address::class, ['data' => $addressData[0]]);
31 $shippingAddress->setAddressType('shipping');
32 
34 $billingAddress->setId(null)
35  ->setAddressType('billing');
36 
39  Quote::class,
40  [
41  'data' => [
42  'customer_id' => $customer->getId(),
43  'store_id' => $store->getId(),
44  'reserved_order_id' => '0000032134',
45  'is_active' => true,
46  'is_multishipping' => false
47  ]
48  ]
49 );
50 $quote->setShippingAddress($shippingAddress)
51  ->setBillingAddress($billingAddress)
52  ->addProduct($product);
53 
54 $quote->getPayment()
55  ->setMethod('checkmo');
56 $quote->getShippingAddress()
57  ->setShippingMethod('flatrate_flatrate')
58  ->setCollectShippingRates(true);
59 $quote->collectTotals();
60 
62 $repository = $objectManager->get(CartRepositoryInterface::class);
63 $repository->save($quote);
$objectManager
$customer
Definition: customers.php:11
return false
Definition: gallery.phtml:36
$addressData
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
$shippingAddress
$billingAddress