1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Codexshaper\WooCommerce\PHP\Models; |
4
|
|
|
|
5
|
|
|
use Codexshaper\WooCommerce\PHP\QueryBuilderTrait; |
6
|
|
|
|
7
|
|
|
class ShippingZone extends BaseModel |
8
|
|
|
{ |
9
|
|
|
use QueryBuilderTrait; |
10
|
|
|
|
11
|
|
|
protected $endpoint = 'shipping/zones'; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Retrieve all Items. |
15
|
|
|
* |
16
|
|
|
* @param int $id |
17
|
|
|
* @param array $options |
18
|
|
|
* |
19
|
|
|
* @return array |
20
|
|
|
*/ |
21
|
|
|
protected function getLocations($id, $options = []) |
22
|
|
|
{ |
23
|
|
|
$this->endpoint = "shipping/zones/{$id}/locations"; |
24
|
|
|
self::all($options); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Update Existing Item. |
29
|
|
|
* |
30
|
|
|
* @param int $id |
31
|
|
|
* @param array $data |
32
|
|
|
* |
33
|
|
|
* @return object |
34
|
|
|
*/ |
35
|
|
|
protected function updateLocations($id, $data = []) |
36
|
|
|
{ |
37
|
|
|
$this->endpoint = "shipping/zones/{$id}/locations"; |
38
|
|
|
self::update($data); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Create new Item. |
43
|
|
|
* |
44
|
|
|
* @param int $id |
45
|
|
|
* @param array $data |
46
|
|
|
* |
47
|
|
|
* @return object |
48
|
|
|
*/ |
49
|
|
|
protected function addShippingZoneMethod($id, $data) |
50
|
|
|
{ |
51
|
|
|
$this->endpoint = "shipping/zones/{$id}/methods"; |
52
|
|
|
self::create($data); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Retrieve single Item. |
57
|
|
|
* |
58
|
|
|
* @param int $zone_id |
59
|
|
|
* @param int $id |
60
|
|
|
* @param array $options |
61
|
|
|
* |
62
|
|
|
* @return object |
63
|
|
|
*/ |
64
|
|
|
protected function getShippingZoneMethod($zone_id, $id, $options = []) |
65
|
|
|
{ |
66
|
|
|
$this->endpoint = "shipping/zones/{$zone_id}/methods"; |
67
|
|
|
self::find($id, $options); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Retrieve all Items. |
72
|
|
|
* |
73
|
|
|
* @param int $id |
74
|
|
|
* @param array $options |
75
|
|
|
* |
76
|
|
|
* @return array |
77
|
|
|
*/ |
78
|
|
|
protected function getShippingZoneMethods($id, $options = []) |
79
|
|
|
{ |
80
|
|
|
$this->endpoint = "shipping/zones/{$id}/methods"; |
81
|
|
|
self::all($options); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Update Existing Item. |
86
|
|
|
* |
87
|
|
|
* @param int $zone_id |
88
|
|
|
* @param int $id |
89
|
|
|
* @param array $data |
90
|
|
|
* |
91
|
|
|
* @return object |
92
|
|
|
*/ |
93
|
|
|
protected function updateShippingZoneMethod($zone_id, $id, $data = []) |
94
|
|
|
{ |
95
|
|
|
$this->endpoint = "shipping/zones/{$zone_id}/methods"; |
96
|
|
|
self::update($id, $data); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Destroy Item. |
101
|
|
|
* |
102
|
|
|
* @param int $zone_id |
103
|
|
|
* @param int $id |
104
|
|
|
* @param array $options |
105
|
|
|
* |
106
|
|
|
* @return object |
107
|
|
|
*/ |
108
|
|
|
protected function deleteShippingZoneMethod($zone_id, $id, $options = []) |
109
|
|
|
{ |
110
|
|
|
$this->endpoint = "shipping/zones/{$zone_id}/methods"; |
111
|
|
|
self::delete($id, $options); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|