Skip to main content
Published: June 17 2005, 5:27:00 PMUpdated: July 21 2022, 9:59:43 AM

As a seller, how do I find out in which order the buyer placed an item?

If you do not know the OrderID of the order which contains your item, you need to use GetOrders to get a list of all the orders for a date range. Then you need to iterate through each of the orders and within each order, iterate through each of the transactions, to check if it contains the ItemID that you need.

A couple of points to keep in mind when you use GetOrders:

  • If the order is completed, then you will to look in the orders with the OrderStatus set to Completed, otherwise you would need to check the ones that are Active or Cancelled.
  • Remember that the date range is in GMT, so make sure that you account for it when you set the range.

Here is a code snippet that uses SDK to look in the completed orders for the last seven days and find the Order that contains the item:

using System;
using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Util;
using eBay.Service.Core.Soap;

namespace SDK3Examples
{

public class GetOrdersExample
{
public ApiContext GetContext()
{
ApiContext context = new ApiContext();

// Credentials for the call
context.ApiCredential.ApiAccount.Developer = "devID";
context.ApiCredential.ApiAccount.Application = "appID";
context.ApiCredential.ApiAccount.Certificate = "certID";
context.ApiCredential.eBayToken = "token";

// Set the URL
context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi";
// Set logging
context.ApiLogManager = newApiLogManager();
context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("Messages.log", true, true, true));
context.ApiLogManager.EnableLogging = true;

// Set the version
context.Version = "595";

return context;

}

public string GetOrders( string ItemID)
{

OrderTypeCollection otc;
try
{
GetOrdersCall getOrders = new GetOrdersCall(GetContext());

//Get the orders for the last 7 days
otc = getOrders.GetOrders( DateTime.Now.AddDays(-7) , DateTime.Now, TradingRoleCodeType.Seller, OrderStatusCodeType.Completed);

//iterate through the OrderTyeCollection
foreach(OrderType ot in otc)
{

//iterate through the TransactionArray
for(int i = 0;i < ot.TransactionArray.Count; i++)
{
//iterate through the Items
ItemType it = ot.TransactionArray[i].Item;
if(it.ItemID == ItemID)
{
//This is the order we are looking for
//ot.OrderID is the order ID
//now we do the required processing
}
}
}
}
catch(ApiException ex)
{
//Handle the exception
}
}
}
} >

How well did this answer your question?
Answers others found helpful

Got thoughts? Click the feedback button – your insights help us improve!