1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ShopperLibrary\ObjectModule; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class WoocommerceObjectModule |
7
|
|
|
* @package ShopperLibrary\ObjectModule |
8
|
|
|
*/ |
9
|
|
|
class WoocommerceObjectModule extends ObjectModuleAbstract implements ObjectModuleInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var bool |
13
|
|
|
*/ |
14
|
|
|
public $includeSimulator; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Woocommerce Cart Object |
18
|
|
|
* |
19
|
|
|
* @var mixed |
20
|
|
|
*/ |
21
|
|
|
public $cart; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Woocommerce Address Object |
25
|
|
|
* |
26
|
|
|
* @var mixed |
27
|
|
|
*/ |
28
|
|
|
public $woShippingAddress; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Woocommerce Address Object |
32
|
|
|
* |
33
|
|
|
* @var mixed |
34
|
|
|
*/ |
35
|
|
|
public $woBillingAddress; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Woocommerce Order Object |
39
|
|
|
* |
40
|
|
|
* @var mixed |
41
|
|
|
*/ |
42
|
|
|
public $order; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Woocommerce Customer Object |
46
|
|
|
* |
47
|
|
|
* @var mixed |
48
|
|
|
*/ |
49
|
|
|
public $customer; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return bool |
53
|
|
|
*/ |
54
|
|
|
public function isIncludeSimulator() |
55
|
|
|
{ |
56
|
|
|
return $this->includeSimulator; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param bool $includeSimulator |
61
|
|
|
* |
62
|
|
|
* @return WoocommerceObjectModule |
63
|
|
|
*/ |
64
|
|
|
public function setIncludeSimulator($includeSimulator) |
65
|
|
|
{ |
66
|
|
|
$this->includeSimulator = $includeSimulator; |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
|
|
public function getCart() |
75
|
|
|
{ |
76
|
|
|
return json_decode($this->cart); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param mixed $cart |
81
|
|
|
* |
82
|
|
|
* @return WoocommerceObjectModule |
83
|
|
|
*/ |
84
|
|
|
public function setCart($cart) //WC_Cart Object |
85
|
|
|
{ |
86
|
|
|
$this->cart = json_encode($cart); |
87
|
|
|
|
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return mixed |
93
|
|
|
*/ |
94
|
|
|
public function getOrder() |
95
|
|
|
{ |
96
|
|
|
return json_decode($this->order); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param mixed $order |
101
|
|
|
* |
102
|
|
|
* @return WoocommerceObjectModule |
103
|
|
|
*/ |
104
|
|
|
public function setOrder($order) //WC_Order Object |
105
|
|
|
{ |
106
|
|
|
$this->order = $order->__toString(); |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return mixed |
113
|
|
|
*/ |
114
|
|
|
public function getWoShippingAddress() |
115
|
|
|
{ |
116
|
|
|
return $this->woShippingAddress; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param mixed $order |
121
|
|
|
* |
122
|
|
|
* @return WoocommerceObjectModule |
123
|
|
|
*/ |
124
|
|
|
public function setWoShippingAddress($order) //WC_Order Object |
125
|
|
|
{ |
126
|
|
|
if(method_exists($order,'get_address')) { |
127
|
|
|
$this->woShippingAddress = (Object)$order->get_address('shipping'); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @return mixed |
135
|
|
|
*/ |
136
|
|
|
public function getWoBillingAddress() |
137
|
|
|
{ |
138
|
|
|
return $this->woBillingAddress; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param mixed $order |
143
|
|
|
* |
144
|
|
|
* @return WoocommerceObjectModule |
145
|
|
|
*/ |
146
|
|
|
public function setWoBillingAddress($order) //WC_Order Object |
147
|
|
|
{ |
148
|
|
|
if(method_exists($order,'get_address')) { |
149
|
|
|
$this->woBillingAddress = (Object)$order->get_address('billing'); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return mixed |
157
|
|
|
*/ |
158
|
|
|
public function getCustomer() |
159
|
|
|
{ |
160
|
|
|
return $this->customer; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param $customer |
165
|
|
|
* |
166
|
|
|
* @return $this |
167
|
|
|
*/ |
168
|
|
|
public function setCustomer($customer) |
169
|
|
|
{ |
170
|
|
|
$this->customer = $customer; |
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* I have nothing to prepare. |
176
|
|
|
*/ |
177
|
|
|
public function prepare() |
178
|
|
|
{ |
179
|
|
|
return; |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|