@@ -135,28 +135,7 @@ protected function parseXML($xml) {
135135 $ this ->order ['Details ' ]['DeliveryWindow ' ]['StartDateTime ' ] = (string )$ d ->DeliveryWindow ->StartDateTime ;
136136 $ this ->order ['Details ' ]['DeliveryWindow ' ]['EndDateTime ' ] = (string )$ d ->DeliveryWindow ->EndDateTime ;
137137 }
138- //Address
139- $ this ->order ['Details ' ]['DestinationAddress ' ]['Name ' ] = (string )$ d ->DestinationAddress ->Name ;
140- $ this ->order ['Details ' ]['DestinationAddress ' ]['Line1 ' ] = (string )$ d ->DestinationAddress ->Line1 ;
141- if (isset ($ d ->DestinationAddress ->Line2 )){
142- $ this ->order ['Details ' ]['DestinationAddress ' ]['Line2 ' ] = (string )$ d ->DestinationAddress ->Line2 ;
143- }
144- if (isset ($ d ->DestinationAddress ->Line3 )){
145- $ this ->order ['Details ' ]['DestinationAddress ' ]['Line3 ' ] = (string )$ d ->DestinationAddress ->Line3 ;
146- }
147- if (isset ($ d ->DestinationAddress ->DistrictOrCounty )){
148- $ this ->order ['Details ' ]['DestinationAddress ' ]['DistrictOrCounty ' ] = (string )$ d ->DestinationAddress ->DistrictOrCounty ;
149- }
150- $ this ->order ['Details ' ]['DestinationAddress ' ]['City ' ] = (string )$ d ->DestinationAddress ->City ;
151- $ this ->order ['Details ' ]['DestinationAddress ' ]['StateOrProvinceCode ' ] = (string )$ d ->DestinationAddress ->StateOrProvinceCode ;
152- $ this ->order ['Details ' ]['DestinationAddress ' ]['CountryCode ' ] = (string )$ d ->DestinationAddress ->CountryCode ;
153- if (isset ($ d ->DestinationAddress ->PostalCode )){
154- $ this ->order ['Details ' ]['DestinationAddress ' ]['PostalCode ' ] = (string )$ d ->DestinationAddress ->PostalCode ;
155- }
156- if (isset ($ d ->DestinationAddress ->PhoneNumber )){
157- $ this ->order ['Details ' ]['DestinationAddress ' ]['PhoneNumber ' ] = (string )$ d ->DestinationAddress ->PhoneNumber ;
158- }
159- //End of Address
138+ $ this ->order ['Details ' ]['DestinationAddress ' ] = $ this ->parseAddress ($ d ->DestinationAddress );
160139 if (isset ($ d ->FulfillmentAction )){
161140 $ this ->order ['Details ' ]['FulfillmentAction ' ] = (string )$ d ->FulfillmentAction ;
162141 }
@@ -279,6 +258,78 @@ protected function parseXML($xml) {
279258
280259 $ i ++;
281260 }
261+
262+ //Section 4: Return Items
263+ if (isset ($ xml ->ReturnItemList )) {
264+ foreach ($ xml ->ReturnItemList ->children () as $ x ) {
265+ $ temp = array ();
266+ $ temp ['SellerReturnItemId ' ] = (string )$ x ->SellerReturnItemId ;
267+ $ temp ['SellerFulfillmentOrderItemId ' ] = (string )$ x ->SellerFulfillmentOrderItemId ;
268+ $ temp ['AmazonShipmentId ' ] = (string )$ x ->AmazonShipmentId ;
269+ $ temp ['SellerReturnReasonCode ' ] = (string )$ x ->SellerReturnReasonCode ;
270+ if (isset ($ x ->ReturnComment )) {
271+ $ temp ['ReturnComment ' ] = (string )$ x ->ReturnComment ;
272+ }
273+ if (isset ($ x ->AmazonReturnReasonCode )) {
274+ $ temp ['AmazonReturnReasonCode ' ] = (string )$ x ->AmazonReturnReasonCode ;
275+ }
276+ $ temp ['Status ' ] = (string )$ x ->Status ;
277+ $ temp ['StatusChangedDate ' ] = (string )$ x ->StatusChangedDate ;
278+ if (isset ($ x ->ReturnAuthorizationId )) {
279+ $ temp ['ReturnAuthorizationId ' ] = (string )$ x ->ReturnAuthorizationId ;
280+ }
281+ if (isset ($ x ->ReturnReceivedCondition )) {
282+ $ temp ['ReturnReceivedCondition ' ] = (string )$ x ->ReturnReceivedCondition ;
283+ }
284+ if (isset ($ x ->FulfillmentCenterId )) {
285+ $ temp ['FulfillmentCenterId ' ] = (string )$ x ->FulfillmentCenterId ;
286+ }
287+ $ this ->order ['ReturnItems ' ][] = $ temp ;
288+ }
289+ }
290+
291+ //Section 5: Return Authorizations
292+ if (isset ($ xml ->ReturnAuthorizationList )) {
293+ foreach ($ xml ->ReturnAuthorizationList ->children () as $ x ) {
294+ $ temp = array ();
295+ $ temp ['ReturnAuthorizationId ' ] = (string )$ x ->ReturnAuthorizationId ;
296+ $ temp ['FulfillmentCenterId ' ] = (string )$ x ->FulfillmentCenterId ;
297+ $ temp ['ReturnToAddress ' ] = $ this ->parseAddress ($ x ->ReturnToAddress );
298+ $ temp ['AmazonRmaId ' ] = (string )$ x ->AmazonRmaId ;
299+ $ temp ['RmaPageURL ' ] = (string )$ x ->RmaPageURL ;
300+ $ this ->order ['ReturnAuthorizations ' ][] = $ temp ;
301+ }
302+ }
303+ }
304+
305+ /**
306+ * Parses XML for an address into an array.
307+ * @param SimpleXMLElement $xml <p>Address node of the XML response from Amazon.</p>
308+ * @return array Parsed structure from XML
309+ */
310+ public function parseAddress ($ xml ) {
311+ $ r = array ();
312+ $ r ['Name ' ] = (string )$ xml ->Name ;
313+ $ r ['Line1 ' ] = (string )$ xml ->Line1 ;
314+ if (isset ($ xml ->Line2 )){
315+ $ r ['Line2 ' ] = (string )$ xml ->Line2 ;
316+ }
317+ if (isset ($ xml ->Line3 )){
318+ $ r ['Line3 ' ] = (string )$ xml ->Line3 ;
319+ }
320+ if (isset ($ xml ->DistrictOrCounty )){
321+ $ r ['DistrictOrCounty ' ] = (string )$ xml ->DistrictOrCounty ;
322+ }
323+ $ r ['City ' ] = (string )$ xml ->City ;
324+ $ r ['StateOrProvinceCode ' ] = (string )$ xml ->StateOrProvinceCode ;
325+ $ r ['CountryCode ' ] = (string )$ xml ->CountryCode ;
326+ if (isset ($ xml ->PostalCode )){
327+ $ r ['PostalCode ' ] = (string )$ xml ->PostalCode ;
328+ }
329+ if (isset ($ xml ->PhoneNumber )){
330+ $ r ['PhoneNumber ' ] = (string )$ xml ->PhoneNumber ;
331+ }
332+ return $ r ;
282333 }
283334
284335 /**
@@ -323,6 +374,8 @@ public function cancelOrder(){
323374 * <li><b>Details</b> - array of general information, such as destination address</li>
324375 * <li><b>Items</b> - multi-dimensional array of item data</li>
325376 * <li><b>Shipments</b> - multi-dimensional array of shipment data</li>
377+ * <li><b>ReturnItems</b> - multi-dimensional array of return item data</li>
378+ * <li><b>ReturnAuthorizations</b> - multi-dimensional array of return authorization data</li>
326379 * </ul>
327380 * @return array|boolean data array, or <b>FALSE</b> if data not filled yet
328381 */
0 commit comments