Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_payflowpro.php
Go to the documentation of this file.
1 <?php
14 
15 require 'fixed_discount.php';
16 
18 $objectManager = Bootstrap::getObjectManager();
19 
21  'firstname' => 'John',
22  'lastname' => 'Doe',
23  'company' => '',
24  'email' => '[email protected]',
25  'street' => [
26  0 => 'test1',
27  ],
28  'city' => 'Test',
29  'region_id' => '1',
30  'region' => '',
31  'postcode' => '9001',
32  'country_id' => 'US',
33  'telephone' => '11111111',
34 ];
36 $billingAddress = $objectManager->create(Address::class, ['data' => $addressData]);
37 $billingAddress->setAddressType('billing');
38 
40 $shippingAddress->setAddressType('shipping')
41  ->setId(null);
42 
44 $quote = $objectManager->create(Quote::class);
45 $quote->setCustomerIsGuest(true)
46  ->setReservedOrderId('100000015')
47  ->setBillingAddress($billingAddress)
48  ->setShippingAddress($shippingAddress);
49 
51 $productRepository = $objectManager->get(ProductRepositoryInterface::class);
52 for ($i = 1; $i <= 3; $i++) {
54  $product = $objectManager->create(ProductInterface::class);
55  $product->setTypeId('simple')
56  ->setName('Simple ' . $i)
57  ->setSku('simple' . $i)
58  ->setAttributeSetId(4)
59  ->setPrice(5.69 + $i * 2)
60  ->setWeight(1);
61 
63  $stockItem = $objectManager->create(StockItemInterface::class);
64  $stockItem->setQty(10)
65  ->setIsInStock(true);
66  $extensionAttributes = $product->getExtensionAttributes();
67  $extensionAttributes->setStockItem($stockItem);
68 
70  $quote->addProduct($item, $i);
71 }
72 
73 $quote->setCouponCode($coupon->getCode());
74 $quote->collectTotals();
75 
77 $quoteRepository = $objectManager->get(QuoteRepository::class);
$shippingAddress
$coupon
$addressData
$quoteRepository
$extensionAttributes
Definition: payment.php:22
$objectManager
$i
Definition: gallery.phtml:31
$productRepository
$billingAddress