如何获得订单ebay getOrders API的总运费

时间:2013-08-27 06:41:58

标签: c# ebay-api getorders

我试图通过API中的eBay GetOrders调用来获取订单的总运费。我创建了一个测试订单,其中包含1个带免费邮资的项目,一个带有计算运费的项目,以及一个带有固定运费的项目(涵盖所有情景)。

我尝试使用TransactionArray / Transaction / ActualShippingCost获取每件商品的运费,然后再添加总额。我也试过ShippingDetails / ShippingServiceOptions / ShippingServiceCost,但我似乎无法弄明白。

这是我可以提出的最新代码,但它会不断报告错误:“对象引用未设置为对象的实例”

double ShippingCost = 0.00;
foreach (TransactionType transaction in orderTrans)
{

    ShippingCost += transaction.ActualShippingCost.Value; //this line causes error
}
MessageBox.Show("Total Shipping Cost is: " + ShippingCost.ToString());

1 个答案:

答案 0 :(得分:1)

尝试从订单中阅读运费:

if (order.ShippingServiceSelected.ShippingServiceCost != null)
{
    ShippingCost = order.ShippingServiceSelected.ShippingServiceCost.Value
}

我们在代码中使用此方法,它可以正常工作。