sp-api-sdk
sp-api-sdk copied to clipboard
Convert protected object/array to public
I'm working on getting orders from amazon and I'm building an array with the full information for the order, such as Items, however, it is like I cannot do anything with the original order array or orders array.
Am I doing something wrong? or how can I access this another way as we do manipulation to the orders coming in so that we can enter them into out system.
`$orderArr = array();
// new order get
$order_statuses = array(SPOrder::ORDER_STATUS_UNSHIPPED, SPOrder::ORDER_STATUS_SHIPPED);
$orders = $this->sdk->orders()->getOrders(
$this->accessToken,
Regions::NORTH_AMERICA,
$marketplaceId = [Marketplace::US()->id()],
$date,
null,
null,
null,
$order_statuses
);
//error_log('orders:'); error_log(json_encode($orders));
if (isset($orders['payload']['orders'])) { $orders = $orders['payload']['orders']; }
//$orders = json_encode($orders);
//$orders = json_decode($orders, true, 5, JSON_OBJECT_AS_ARRAY);
//dump($orders); exit;
$c = 0;
foreach ($orders as $order) {
if($this->isFlowOrder($order['amazon_order_id'])) {
continue;
}
$orderId = $order['amazon_order_id'];
//$order = $this->object_to_array($order);
$orderArr[$c] = $order;
$items = $this->sdk->orders()->getOrderItems(
$this->accessToken,
Regions::NORTH_AMERICA,
$orderId
);
$orderArr[$c]['Items'] = $this->object_to_array($items['payload']['order_items']);
$c++;
}
return (array) $orderArr;`