forked from afosto/active-ants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
64 lines (45 loc) · 1.45 KB
/
index.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
<?php
namespace ActiveAnts;
require_once(dirname(__FILE__) . '/vendor/autoload.php');
//Include our configs
require_once(dirname(__FILE__) . '/../config.php');
//Make sure this directory is writable
$cacheDirectory = dirname(__FILE__) . '/../cache/';
App::start($url, $user, $password, $cacheDirectory);
$product = Product::model()
->setName('testProduct')
->setSku('testSku');
if (!$product->save()) {
echo $product->getMessage();
}
$item = OrderItem::model()
->setSku('testSku', false)
->setGrossPrice(1.21)
->setName('testProduct')
->setTaxRate(21);
$address = Address::model()
->setName('Afosto SaaS BV')
->setAddress('Protonstraat', 9, 'a')
->setCity('Groningen')
->setCountry('NL')
->setPostalcode('9743AL');
$order = Order::model()
->setEmail('support@afosto.com')
->setOrderId('#' . 1000)
->setPhoneNumber('test')
->addOrderItem($item)
->setBillingAddress($address)
->setShippingAddress();
//$order->setPickupPoint('NL-111101', '1111AA', 'Straatnaam 10a' , 'Groningen');
if (!$order->save()) {
echo $order->getMessage();
}
$purchase = PurchaseOrder::model()
->addItem('testSku', 1)
->addReference('testPurchaseOrder');
if (!$purchase->save()) {
echo $purchase->getMessage();
}
foreach (Stock::model()->findAll() as $stock) {
echo $stock->sku . ': ' . $stock->stock . "\n";
}