-
Notifications
You must be signed in to change notification settings - Fork 7
/
place-order.php
75 lines (67 loc) · 2.09 KB
/
place-order.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require_once 'api.php';
// The URL to your Magento 2 instance (ending with /index.php/rest/V1)
$api_url = 'http://YOUR-MAGENTO_DOMAIN/index.php/rest/V1';
// Set the integrations access token.
$token = 'YOUR-ACCESS-TOKEN';
// Fill in the SKU of the product which should be ordered.
$sku = 'PRODUCT-SKU-TO-ORDER';
$magento = new MagentoClient($token, $api_url);
$product = $magento->getProduct($sku);
$cart = $magento->createCart();
$cart = str_replace('"', '', $cart);
$order_filled = $magento->addToCart($cart, $sku, 1);
//var_dump($order_filled);
$ship_to = array (
'addressInformation' =>
array (
'shippingAddress' =>
array (
'region' => 'Wien',
'region_id' => 95,
'country_id' => 'AT',
'street' =>
array (
0 => 'Fillgradergasse 12-14/1a',
),
'company' => 'acolono GmbH',
'telephone' => '1111111',
'postcode' => '1060',
'city' => 'Vienna',
'firstname' => 'Martin',
'lastname' => 'Testman',
'email' => '[email protected]',
'prefix' => 'address_',
'region_code' => 'W',
'sameAsBilling' => 1,
),
'billingAddress' =>
array (
'region' => 'Wien',
'region_id' => 95,
'country_id' => 'AT',
'street' =>
array (
0 => 'Fillgradergasse 12-14/1a',
),
'company' => 'acolono GmbH',
'telephone' => '1111111',
'postcode' => '1060',
'city' => 'Vienna',
'firstname' => 'Martin',
'lastname' => 'Testman',
'email' => '[email protected]',
'prefix' => 'address_',
'region_code' => 'W',
),
'shipping_method_code' => 'flatrate',
'shipping_carrier_code' => 'flatrate',
),
);
$order_shipment = $magento->setShipping($cart, $ship_to);
// var_dump($order_shipment);
//$payment = $magento->getPaymentMethods($cart);
//var_dump($payment);
$ordered = $magento->placeOrder($cart, 'cashondelivery');
echo "\nordered:\n";
var_dump($ordered);