Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
order_with_downloadable_product_with_additional_options.php
Go to the documentation of this file.
1 <?php
8  \Magento\Sales\Model\Order\Address::class,
9  [
10  'data' => [
11  'firstname' => 'guest',
12  'lastname' => 'guest',
13  'email' => '[email protected]',
14  'street' => 'street',
15  'city' => 'Los Angeles',
16  'region' => 'CA',
17  'postcode' => '1',
18  'country_id' => 'US',
19  'telephone' => '1',
20  ]
21  ]
22 );
23 $billingAddress->setAddressType('billing');
24 
26  \Magento\Sales\Model\Order\Payment::class
27 );
28 $payment->setMethod('checkmo');
29 
31  \Magento\Sales\Model\Order\Item::class
32 );
33 $orderItem->setProductId(
34  1
35 )->setProductType(
36  \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
37 )->setBasePrice(
38  100
39 )->setQtyOrdered(
40  1
41 );
42 $orderItem->setProductOptions(['additional_options' => ['additional_option_key' => 'additional_option_value']]);
43 
45 $order->setCustomerEmail(
47 )->addItem(
49 )->setIncrementId(
50  '100000001'
51 )->setCustomerIsGuest(
52  true
53 )->setStoreId(
54  1
55 )->setEmailSent(
56  1
57 )->setBillingAddress(
59 )->setPayment(
60  $payment
61 );
62 $order->save();