1 | <?php |
||
15 | class Order |
||
16 | { |
||
17 | /** |
||
18 | * Order reference: unique ID used in your web shop to assign to an order. |
||
19 | * The value of this parameter is not managed by bpost. If the value |
||
20 | * already exists, it will update current order info. Existing boxes will |
||
21 | * not be changed, new boxes will be added. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $reference; |
||
26 | |||
27 | /** |
||
28 | * This information is used on your invoice and allows you to attribute |
||
29 | * different cost centers |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $costCenter; |
||
34 | |||
35 | /** |
||
36 | * The items that are included in the order. |
||
37 | * Order lines are shown in the back end of the Shipping Manager and |
||
38 | * facilitate the use of the tool. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | private $lines; |
||
43 | |||
44 | /** |
||
45 | * Box tags |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | private $boxes; |
||
50 | |||
51 | /** |
||
52 | * Create an order |
||
53 | * |
||
54 | * @param string $reference |
||
55 | */ |
||
56 | 2 | public function __construct($reference) |
|
57 | { |
||
58 | 2 | $this->setReference($reference); |
|
59 | 2 | } |
|
60 | |||
61 | /** |
||
62 | * @param Box[] $boxes |
||
63 | */ |
||
64 | 1 | public function setBoxes(array $boxes) |
|
65 | { |
||
66 | 1 | $this->boxes = $boxes; |
|
67 | 1 | } |
|
68 | |||
69 | /** |
||
70 | * @return Box[] |
||
71 | */ |
||
72 | 2 | public function getBoxes() |
|
73 | { |
||
74 | 2 | return $this->boxes; |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * Add a box |
||
79 | * |
||
80 | * @param Box $box |
||
81 | */ |
||
82 | 2 | public function addBox(Box $box) |
|
83 | { |
||
84 | 2 | $this->boxes[] = $box; |
|
85 | 2 | } |
|
86 | |||
87 | /** |
||
88 | * @param string $costCenter |
||
89 | */ |
||
90 | 2 | public function setCostCenter($costCenter) |
|
91 | { |
||
92 | 2 | $this->costCenter = $costCenter; |
|
93 | 2 | } |
|
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | */ |
||
98 | 2 | public function getCostCenter() |
|
99 | { |
||
100 | 2 | return $this->costCenter; |
|
101 | } |
||
102 | |||
103 | /** |
||
104 | * @param Line[] $lines |
||
105 | */ |
||
106 | 1 | public function setLines(array $lines) |
|
107 | { |
||
108 | 1 | $this->lines = $lines; |
|
109 | 1 | } |
|
110 | |||
111 | /** |
||
112 | * @return Line[] |
||
113 | */ |
||
114 | 2 | public function getLines() |
|
115 | { |
||
116 | 2 | return $this->lines; |
|
117 | } |
||
118 | |||
119 | /** |
||
120 | * Add an order line |
||
121 | * |
||
122 | * @param Line $line |
||
123 | */ |
||
124 | 2 | public function addLine(Line $line) |
|
125 | { |
||
126 | 2 | $this->lines[] = $line; |
|
127 | 2 | } |
|
128 | |||
129 | /** |
||
130 | * @param string $reference |
||
131 | */ |
||
132 | 2 | public function setReference($reference) |
|
133 | { |
||
134 | 2 | $this->reference = $reference; |
|
135 | 2 | } |
|
136 | |||
137 | /** |
||
138 | * @return string |
||
139 | */ |
||
140 | 2 | public function getReference() |
|
141 | { |
||
142 | 2 | return $this->reference; |
|
143 | } |
||
144 | |||
145 | /** |
||
146 | * Return the object as an array for usage in the XML |
||
147 | * |
||
148 | * @param \DOMDocument $document |
||
149 | * @param string $accountId |
||
150 | * @return \DOMElement |
||
151 | */ |
||
152 | 1 | public function toXML(\DOMDocument $document, $accountId) |
|
230 | |||
231 | /** |
||
232 | * @param \SimpleXMLElement $xml |
||
233 | * |
||
234 | * @return Order |
||
235 | * @throws BpostXmlNoReferenceFoundException |
||
236 | * @throws BpostNotImplementedException |
||
237 | */ |
||
238 | 2 | public static function createFromXML(\SimpleXMLElement $xml) |
|
239 | { |
||
240 | // @todo work with classmaps ... |
||
241 | 2 | if (!isset($xml->reference)) { |
|
265 | } |
||
266 |