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

本文关键字:ebay getOrders API 何获得 | 更新日期: 2023-09-27 18:29:04

我正在尝试通过API中的易趣GetOrders调用获取订单的总运费。我创建了一个测试订单,其中有一个项目是免费的,一个项目有计算的运输成本,还有一个项目的运输成本是固定的(以涵盖所有场景)。

我尝试过使用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());

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

尝试从订单中读取运输成本:

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

我们在代码中使用了这个方法,它是有效的。