$client=new MCS\MWSClient([
'Marketplace_Id'=>'',
'Seller_Id'=>'',
'Access_Key_ID'=>'',
'Secret_Access_Key'=>'',
'MWSAuthToken'=>''// Optional. Only use this key if you are a third party user/developer
]);
$fromDate=new DateTime('2016-01-01');
$states= ['Unshipped','PartiallyShipped','Shipped','PendingAvailability','Pending','InvoiceUnconfirmed','Canceled','Unfulfillable'];
$client->ListOrders($fromDate, false, $states);
<?php
/**
* author : forecho <caizhenghai@gmail.com>
* createTime : 2019/6/11 9:53 PM
* description:
*/namespace app\core\helpers;
use Exception;
classMWSClientextends \MCS\MWSClient
{
/**
* Sets the shipping status of an order
* @param array $data required data
* @return array feed submission result
* @throws Exception
*/publicfunctionsetDeliveryState(array$data)
{
if (!isset($data["shippingDate"])) {
$data["shippingDate"] = date("c");
}
if (!isset($data["carrierCode"]) &&!isset($data["carrierName"])) {
thrownew Exception('Missing required carrier data');
}
$feed= [
'MessageType'=>'OrderFulfillment',
'Message'=> [
'MessageID'=> rand(),
"OrderFulfillment"=> [
"AmazonOrderID"=>$data["orderId"],
"FulfillmentDate"=>$data["shippingDate"]
]
]
];
$fulfillmentData= [];
if (isset($data["carrierCode"])) {
$fulfillmentData["CarrierCode"] =$data["carrierCode"];
} elseif (isset($data["carrierName"])) {
$fulfillmentData["CarrierName"] =$data["carrierName"];
}
if (isset($data["shippingMethod"])) {
$fulfillmentData["ShippingMethod"] =$data["shippingMethod"];
}
if (isset($data["trackingCode"])) {
$fulfillmentData["ShipperTrackingNumber"] =$data["trackingCode"];
}
if (sizeof($fulfillmentData) >0) {
$feed["Message"]["OrderFulfillment"]["FulfillmentData"] =$fulfillmentData;
}
$feed=$this->SubmitFeed('_POST_ORDER_FULFILLMENT_DATA_', $feed);
return$feed;
}
}
然后修改第一步调用 MWSClient 类的时候使用我们自己的类:
1
2
3
4
5
6
7
$client=new app\core\helpers\MWSClient([
'Marketplace_Id'=>'',
'Seller_Id'=>'',
'Access_Key_ID'=>'',
'Secret_Access_Key'=>'',
'MWSAuthToken'=>''// Optional. Only use this key if you are a third party user/developer
]);