forked from RUDIWER/bol-plaza-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
executable file
·85 lines (69 loc) · 2.73 KB
/
example.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
76
77
78
79
80
81
82
83
84
85
<?php
require_once 'vendor/autoload.php';
$publicKey = '<publicKey>';
$privateKey = '<privateKey>';
// For live enviroment, set the 3rd parameter to false or remove it
$client = new MCS\BolPlazaClient($publicKey, $privateKey, true);
// Get all currently open orders
$orders = $client->getOrders();
if ($orders) {
foreach ($orders as $order) {
print_r($order);
}
}
// Get an order by it's id and ship it
$order = $client->getOrder('123');
if ($order) {
// Bol.com requires you to add an expected deliverydate to a shipment
$deliveryDate = new DateTime('20-6-2014');
// This client also provides a helper function to calculate the next deliverydate
$deliveryDate = $client->nextDeliveryDate(
'18:00', // Until what time are orders shipped this day?
['Sun', 'Mon'], // On what days does the carrier not deliver packages?
['Sat', 'Sun'], // On what days does the carrier not pickup/collect packages?
'12:00' // The time of the delivery
);
// Ship an order with track and trace. See https://developers.bol.com/documentatie/plaza-api/appendix-a-transporters/ for supported carrier codes
$shipped = $order->ship($deliveryDate, 'TNT', '3STEST1234567');
// Ship an order without track and trace
// $shipped = $order->ship($deliveryDate);
print_r($shipped);
}
// Request a csv export containing all your products.
$offerFile = $client->requestOfferFile();
// Wait up to 15 minutes.
$offers = $client->getOffers($offerFile);
//Update an offer's stock
$offerId = 'k001';
$quantity = 20;
$update = $client->updateOfferStock($offerId, $quantity);
if ($update) {
echo 'Offer stock updated';
}
$update = $client->updateOffer('k001', [
'Price' => 12.95,
'DeliveryCode' => '24uurs-21', // https://developers.bol.com/documentatie/plaza-api/appendix-c-delivery-codes/
'Publish' => true,
'ReferenceCode' => 'sku001',
'Description' => 'Description...'
]);
if ($update) {
echo 'Offer updated';
}
$created = $client->createOffer('k002', [
'EAN' => '8711145678987',
'Condition' => 'NEW', // https://developers.bol.com/documentatie/plaza-api/appendix-b-conditions/
'Price' => 189.99,
'DeliveryCode' => '24uurs-21',
'QuantityInStock' => 100,
'Publish' => true,
'ReferenceCode' => 'sku002',
'Description' => 'Description...'
]);
if ($created) {
echo 'Offer created';
}
$delete = $client->deleteOffer('k001');
if ($delete) {
echo 'Offer deleted';
}