Hello,
In my previous blog I mentioned about Channel Advisor API. You can read that blog here. In this blog we will see how to use Channel Advisor Order service to get order details from Channel Advisor. This service is useful when you want to import orders from Channel Advisor to your own CMS or ERP. In my case I was working with Magento – Channel Advisor synchronization. So the requirement was to get order from Channel Advisor and add order to Magento.
Following is the code to create soap client for order service.
$client = new SoapClient(“https://api.channeladvisor.com/ChannelAdvisorAPI/v4/OrderService.asmx?WSDL”);
$headersData = array(‘DeveloperKey’ => $developerKey, ‘Password’ => $password);
$head = new SoapHeader(“http://api.channeladvisor.com/webservices/”,”APICredentials”,$headersData);
$client->__setSoapHeaders($head);
To get necessary order details, we need to set order criteria. Following is the example of order criteria.
$OrderCriteria = array(
‘OrderCreationFilterBeginTimeGMT’=> $date1,
‘OrderCreationFilterEndTimeGMT’=> $date2,
‘StatusUpdateFilterBeginTimeGMT’ => $date1,
‘StatusUpdateFilterEndTimeGMT’ => $date2,
‘DetailLevel’ => ‘Complete’,
‘ExportState’ => ‘NotExported’,
‘OrderStateFilter’ => ‘Active’,
‘PaymentStatusFilter’ => ‘Cleared’,
‘CheckoutStatusFilter’ => ‘Completed’,
‘ShippingStatusFilter’ =>’Shipped’,
‘PageNumberFilter’=>1,
‘PageSize’=>30
);
Here date1 and date2 variable specify date range for orders. After this call function of API to get order data.
$arrData = array(
‘accountID’=>$accountID,
‘orderCriteria’=>$OrderCriteria
);
$result=$client->GetOrderList($arrData);
You will get API response in $result. If there is only one order matching criteria then it will return order object else it will return order object array if more than one order is matching criteria.