Using an API from our provider, I am getting the following data back from an API call:
Data (represents an orderid (1604) and then the individual items within the order):
object(stdClass)#395 (1) {
["GetOrderDetailsInfoResult"]=> object(stdClass)#396 (4) {
["RequestID"]=> int(113724)
["Success"]=> int(1)
["Message"]=> string(0) ""
["OrderDetailsResponse"]=> object(stdClass)#397 (1) {
["OrderDetailsResponse"]=> array(2) {
[0]=> object(stdClass)#53 (12) {
["OrderID"]=> int(1604)
["PartyID"]=> int(0)
["OrderDetailID"]=> int(805)
["ProductID"]=> string(3) "B25"
["Description"]=> string(16) "50 Credits"
["Quantity"]=> int(1)
["Price"]=> string(7) "25.0000"
["Volume"]=> string(7) "25.0000"
["Tax"]=> string(6) "0.0000"
["TaxableAmount"]=> string(6) "0.0000"
["GroupOwner"]=> int(0)
["ParentOrderDetailID"]=> int(0)
}
[1]=> object(stdClass)#419 (12) {
["OrderID"]=> int(1604)
["PartyID"]=> int(0)
["OrderDetailID"]=> int(807)
["ProductID"]=> string(4) "B100"
["Description"]=> string(17) "200 Credits"
["Quantity"]=> int(1)
["Price"]=> string(8) "100.0000"
["Volume"]=> string(8) "100.0000"
["Tax"]=> string(6) "0.0000"
["TaxableAmount"]=> string(6) "0.0000"
["GroupOwner"]=> int(0)
["ParentOrderDetailID"]=> int(0)
}
}
}
}
}
I can get as far as the RequestID, but I can't get into the values for the order... How do I use php to get directly at the individual items?
Thanks.
The items could be iterated over like this:
foreach($data->GetOrderDetailsInfoResult->OrderDetailsResponse->OrderDetailsResponse as $item)
{
echo $item->ProductID;
echo $item->Description;
echo $item->Quantity;
echo $item->Price;
}