Skip to content

Commit 48005a4

Browse files
committed
Merge pull request #83 from Peardian/items
Added order ID to order item list class
2 parents bc107db + ddf0ffe commit 48005a4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

includes/classes/AmazonOrderItemList.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* required. This object can use tokens when retrieving the list.
2525
*/
2626
class AmazonOrderItemList extends AmazonOrderCore implements Iterator{
27+
protected $orderId;
2728
protected $itemList;
2829
protected $tokenFlag = false;
2930
protected $tokenUseFlag = false;
@@ -140,8 +141,10 @@ public function fetchItems($r = true){
140141
if (is_null($xml->AmazonOrderId)){
141142
$this->log("You just got throttled.",'Warning');
142143
return false;
143-
} else if (isset($this->options['AmazonOrderId']) && $this->options['AmazonOrderId'] && $this->options['AmazonOrderId'] != $xml->AmazonOrderId){
144-
$this->log('You grabbed the wrong Order\'s items! - '.$this->options['AmazonOrderId'].' =/= '.$xml->AmazonOrderId,'Urgent');
144+
}
145+
$this->orderId = (string)$xml->AmazonOrderId;
146+
if (!empty($this->options['AmazonOrderId']) && $this->options['AmazonOrderId'] != $this->orderId){
147+
$this->log('You grabbed the wrong Order\'s items! - '.$this->options['AmazonOrderId'].' =/= '.$this->orderId,'Urgent');
145148
}
146149

147150
$this->parseXML($xml->OrderItems);
@@ -297,6 +300,20 @@ protected function parseXML($xml){
297300
}
298301

299302
}
303+
304+
/**
305+
* Returns the order ID for the items.
306+
*
307+
* This method will return <b>FALSE</b> if the list has not yet been filled.
308+
* @return string|boolean single value, or <b>FALSE</b> if not set yet
309+
*/
310+
public function getOrderId(){
311+
if (isset($this->orderId)){
312+
return $this->orderId;
313+
} else {
314+
return false;
315+
}
316+
}
300317

301318
/**
302319
* Returns the specified order item, or all of them.

0 commit comments

Comments
 (0)