Skylight
Skylight

Reputation: 221

eBay API. Filter "awaiting postage" or "unshipped" orders with delivery details

Spent countless amount of hours digging eBay API docs and could not find anything.

On the seller account I need to get list of all orders with status "Awaiting Postage" or "Unshipped". So I can get XML report of all orders which are currently "Unshipped" with full details about the customers (Shipping address, postage method used etc.)

GetOrders doesn't provide filter for Unshipped orders.
GetSellingManagerSoldListings has such functionality, but doesn't provide any details about customer's shipping details.

Did anyone have such problem?

Thanks in advance.

Upvotes: 2

Views: 4232

Answers (6)

Amir Hajiha
Amir Hajiha

Reputation: 935

That's my 'hacky' way of doing it:

try
{
$ShippedTime = $order->ShippedTime;
if($ShippedTime && isset($ShippedTime))
$ShippedTime = $ShippedTime->format('d-m-Y H:i:s');
else
$ShippedTime = 'awaiting dispatch'; 
}
catch(Exception $e)
{
 $ShippedTime = 'awaiting dispatch'; 
}

Upvotes: 0

Ganesh Krishnan
Ganesh Krishnan

Reputation: 7395

GetOrders has RequiredSellerAction tag which shows the next action the seller has to make.

For unshipped orders it's 'MarkAsShipped'

<PaymentHoldDetails>
<ExpectedReleaseDate>2018-04-20T07:00:00.000Z</ExpectedReleaseDate>
<RequiredSellerActionArray>
<RequiredSellerAction>MarkAsShipped</RequiredSellerAction>
</RequiredSellerActionArray>
<NumOfReqSellerActions>1</NumOfReqSellerActions>
<PaymentHoldReason>CasualSeller on https://www.aihello.com </PaymentHoldReason>
</PaymentHoldDetails>

Upvotes: 0

Govind Totla
Govind Totla

Reputation: 1178

Well, i got the orders to be shipped by following params using php.

$xmlReq = '<?xml version="1.0" encoding="utf-8"?>';
$xmlReq .= '<GetSellingManagerSoldListingsRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
$xmlReq .= '<UserID>'.$YOUR_EBAY_APP_ID.'</UserID>';
$xmlReq .= '<Filter>PaidNotShipped</Filter>';
$xmlReq .= '<Pagination><EntriesPerPage>200</EntriesPerPage><PageNumber>1</PageNumber></Pagination>';
$xmlReq .= '<ErrorLanguage>en_US</ErrorLanguage>';
$xmlReq .= "<Version>$version</Version>";
$xmlReq .= '<WarningLevel>Low</WarningLevel>';
$xmlReq .= "<RequesterCredentials><eBayAuthToken>$YOUR_AUTH_TOKEN</eBayAuthToken></RequesterCredentials>\n";    
$xmlReq .= '</GetSellingManagerSoldListingsRequest>';

I hope you got the filter param "PaidNoTShipped". You will get a order_line_item_id in this response and using this just make a another call with this order line item id GetOrderTransactions and you will get the rest information. Use <DetailLevel>ReturnAll</DetailLevel> in GetOrderTransactions to get extended result. Let me know if you want to know more about api calls.

Upvotes: 0

user4421333
user4421333

Reputation:

I've been searching for a solution to this question for quite some allotted time, also. This is a really old question but I wish it had a more direct answer. Would of saved me hours. @Moazam had the right idea, however really lacked specificity, so here goes. The following answer is written in python, based off/using eBay's Api. (You'd think this would be significantly more simple to find/do)

from ebaysdk.trading import Connection as Trading
from ebaysdk.exception import ConnectionError
import bs4 as bs # beautifulsoup import for parsing xml

try:
    api = Trading(config_file="ebay.yaml") #put ur eBay dev API credentials in yaml file
    response = api.execute('GetSellerTransactions', {}) # dictionary response
    dommy = response.content 

except ConnectionError as e: # spit error if can't connect (ie: wrong api credz)
    print(e)
    print(e.response.dict())

soup = bs.BeautifulSoup(dommy, 'lxml') # parse the API response as xml
tArray = soup.transactionarray 

with open('fullSoldLogXML.xml', 'w+') as xml: # Log file, not required.
    xml.write(str(soup)) # write entire ebay response to log file.

with open('singleTransactions.xml', 'w+') as tranXml: # Another log. Personal reference.
    tranXml.write(str(tArray)) # parse all transactions from transactionarray in xml 

for each in tArray: # tArray is every transaction, in transactionarray)
    print each.shippedtime # print shipped time, if None then hasn't been shipped.

Should output something like this:

<shippedtime>2016-12-18T15:12:22.000Z</shippedtime>
<shippedtime>2016-12-20T00:35:43.000Z</shippedtime>
<shippedtime>2016-12-20T01:50:37.000Z</shippedtime>
None

With this information you could do a try/except loop over each transaction. If shippedtime == None, then you can dissect the order and get useful info like print each.shippingaddress, each.orderlineitemid, each.paidtime etc...

Upvotes: 0

Moazam
Moazam

Reputation: 31

GetOrders doesn't provide filter for Unshipped orders..but if there is object of [ShippedTime] in response of your GetOrders Request that mean the order is shipped for unshipped item you wouldn,t get object of [ShippedTime] ...on this base you can query for unshipped orders

Upvotes: 3

Keyur Padalia
Keyur Padalia

Reputation: 2097

This code worked for me and hope you find it useful

 date_default_timezone_set('Europe/London');
 $page = 0;
 $order_count = 0;
 $shipped_count = 0;
 do
 {
     $page++;


    $feed = <<< EOD
<?xml version="1.0" encoding="utf-8"?>
<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>$auth_token</eBayAuthToken>
</RequesterCredentials>
<OrderRole>Seller</OrderRole>
<OrderStatus>Completed</OrderStatus>
<Pagination>
<EntriesPerPage>100</EntriesPerPage>
<PageNumber>$page</PageNumber>
</Pagination>
<NumberOfDays>7</NumberOfDays>
<ErrorLanguage>en_GB</ErrorLanguage>
<Version>823</Version>
<WarningLevel>High</WarningLevel>
</GetOrdersRequest>?
EOD;

$feed = trim($feed);
     $site_id = 3;//3 For UK
     $call_name = 'GetOrders';
     $headers = array
         (
         'X-EBAY-API-COMPATIBILITY-LEVEL: ' . $compat_level,
         'X-EBAY-API-DEV-NAME: ' . $dev_id,
         'X-EBAY-API-APP-NAME: ' . $app_id,
         'X-EBAY-API-CERT-NAME: ' . $cert_id,
         'X-EBAY-API-CALL-NAME: ' . $call_name,
         'X-EBAY-API-SITEID: ' . $site_id,
     );

     // Send request to eBay and load response in $response
     $connection = curl_init();
     curl_setopt($connection, CURLOPT_URL, $api_endpoint);
     curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($connection, CURLOPT_POST, 1);
     curl_setopt($connection, CURLOPT_POSTFIELDS, $feed);
     curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
     $response = curl_exec($connection);
     curl_close($connection);

     $order_count += substr_count($response, "<Order>");
     $shipped_count += substr_count($response, "<ShippedTime>");
 }
 while(stristr($response, "<HasMoreOrders>true</HasMoreOrders>") != FALSE OR stristr($response, "<HasMoreOrders>true</HasMoreOrders>") != 0);
 $unshipped_orders = $order_count - $shipped_count;

Upvotes: 0

Related Questions