1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Lifeboat\Models; |
4
|
|
|
|
5
|
|
|
use Lifeboat\Resource\ObjectResource; |
6
|
|
|
use Lifeboat\Services\Orders; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class Order |
10
|
|
|
* @package Lifeboat\Models |
11
|
|
|
* |
12
|
|
|
* @property string $Status |
13
|
|
|
* @property string $Fulfillment |
14
|
|
|
* @property string|null $DiscountCode |
15
|
|
|
* @property \DateTime|string $Created |
16
|
|
|
* @property \DateTime|string $LastModified |
17
|
|
|
* @property string $OID |
18
|
|
|
* @property float $Subtotal |
19
|
|
|
* @property float $Tax |
20
|
|
|
* @property float $Delivery |
21
|
|
|
* @property float $Handling |
22
|
|
|
* @property float $Discount |
23
|
|
|
* @property float $Total |
24
|
|
|
* @property \DateTime $PaidOn |
25
|
|
|
* @property \DateTime $DeliveredOn |
26
|
|
|
* @property string $PaymentMethod |
27
|
|
|
* @property string $Provider |
28
|
|
|
* @property int $FulfillmentType |
29
|
|
|
* @property array $Discounts |
30
|
|
|
* @property string $Currency |
31
|
|
|
* @property array $Products |
32
|
|
|
* @property ObjectResource|null $ShipTo |
33
|
|
|
* @property ObjectResource|null $BillTo |
34
|
|
|
* @property array $Waypoints |
35
|
|
|
* @property ObjectResource|null $Route |
36
|
|
|
*/ |
37
|
|
|
class Order extends Model { |
38
|
|
|
|
39
|
|
|
protected static array $casting = [ |
40
|
|
|
'Created' => 'lifeboat_date_formatter', |
41
|
|
|
'LastModified' => 'lifeboat_date_formatter', |
42
|
|
|
'Subtotal' => 'floatval', |
43
|
|
|
'Tax' => 'floatval', |
44
|
|
|
'Delivery' => 'floatval', |
45
|
|
|
'Handling' => 'floatval', |
46
|
|
|
'Discount' => 'floatval', |
47
|
|
|
'Total' => 'floatval', |
48
|
|
|
'PaidOn' => 'lifeboat_date_formatter', |
49
|
|
|
'DeliveredOn' => 'lifeboat_date_formatter', |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
public function model(): string |
56
|
|
|
{ |
57
|
|
|
return 'Order'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return Orders |
62
|
|
|
*/ |
63
|
|
|
public function getService(): Orders |
64
|
|
|
{ |
65
|
|
|
return new Orders($this->getClient()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function FulfillmentType(): string |
72
|
|
|
{ |
73
|
|
|
switch ($this->FulfillmentType) { |
74
|
|
|
case Orders::FULFILLMENT_SHIP: return 'ship'; |
75
|
|
|
case Orders::FULFILLMENT_DELIVER: return 'deliver'; |
76
|
|
|
case Orders::FULFILLMENT_PICKUP: return 'pickup'; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return ''; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
public function FulfillmentStatus(): string |
86
|
|
|
{ |
87
|
|
|
switch ($this->Status) { |
88
|
|
|
case Orders::FULFILLMENT_PENDING: return 'pending'; |
89
|
|
|
case Orders::FULFILLMENT_FULFILLED: return 'fulfilled'; |
90
|
|
|
case Orders::FULFILLMENT_DELIVERED: return 'delivered'; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return ''; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
|
|
public function Status(): string |
100
|
|
|
{ |
101
|
|
|
switch ($this->Status) { |
102
|
|
|
case Orders::STATUS_OPEN: return 'open'; |
103
|
|
|
case Orders::STATUS_PAID: return 'paid'; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
return ''; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|