借助 Content API,您可以通过 shippingsettings 和 accounttax 服务来指定将应用于某个账号中所有商品的税费和运费。如果您想让结果更加精确,可以通过 products 服务在商品级别指定税费和运费。
有关 Google 政策以及指定税费和运费的所有选项的信息,请参阅以下帮助中心文章:
请注意,tax
属性(据此使用 Accounttax 服务)仅适用于面向美国销售的商品。
Accounttax 和 shippingsettings Content API 服务镜像 Merchant Center 界面的功能。
简单示例
对于法国 8 欧元的运费,并根据美国的运输公司费率计算,对于每项配送服务,需要 3-7 天才能送达:
PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
"accountId": <account_id>,
"services": [
{
"name": "Livraison Prioritaire",
"deliveryCountry": "FR",
"currency": "EUR",
"rateGroups": [
{
"singleValue": {
"flatRate": { "currency": "EUR", "value": "8" }
}
}
],
"active": true,
"deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
},
{
"name": "UPS in US",
"deliveryCountry": "US",
"currency": "USD"
"rateGroups": [
{
"singleValue": { "carrierRateName": "ups" },
"carrierRates": [
{
"name": "ups",
"carrierName": "UPS",
"carrierService": "Ground",
"originPostalCode": "10011"
}
]
}
],
"active": true,
"deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 },
}
]
}
要检索可用的运输公司名称和服务,请使用 getsupportedcarriers 方法。
复杂示例
如需在纽约州各地创建免运费促销活动(不收取运费),请为美国其他州使用 UPS,并针对美国各州应用不同的税费,请按照如下方式使用对 Content API 的 accounttax 和 shippingsettings 服务的请求。首先配置运费设置:
PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
"accountId": <account_id>,
"services": [
{
"name": "Eligible for free shipping",
"deliveryCountry": "US",
"rateGroups": [
{
"mainTable": {
"rowHeaders": {
"locations": [
{ "locationIds": ["21167"] }, // NY
{ "locationIds": ["21164", "21139"] } // NJ, CT
]
},
"rows": [
{
"cells": [
{
"flatRate": { "currency": "USD", "value": "0" }
}
]
},
{
"cells": [
{
"flatRate": { "currency": "USD", "value": "0" }
}
]
}
]
}
}
],
"active": true,
"deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 },
"currency": "USD"
},
{
"name": "UPS in US",
"deliveryCountry": "US",
"rateGroups": [
{
"singleValue": { "carrierRateName": "UPS mainland" },
"carrierRates": [
{
"name": "UPS mainland",
"carrierName": "UPS",
"carrierService": "Ground",
"originPostalCode": "10011", // currently only US, AU, and DE postal codes
"percentageAdjustment": "1.05",
"flatAdjustment": { "currency": "USD", "value": "0.75" }
}
]
}
],
"active": true,
"deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 },
"currency": "USD"
}
],
"postalCodeGroups": [
{
"name": "More cities", // An alternative using postal codes
"country": "US",
"postalCodeRanges": [
{ "postalCodeRangeBegin": "94041" },
{ "postalCodeRangeBegin": "94042" },
{ "postalCodeRangeBegin": "94043", "postalCodeRangeEnd": "94045" },
{ "postalCodeRangeBegin": "9405*" },
{ "postalCodeRangeBegin": "9406*", "postalCodeRangeEnd": "9408*" }
]
}
]
}
请注意,地理位置 ID 可用来表示行政区。
接下来,配置税费:
PUT /content/v2.1/<merchant_id>/accounttax/<account_id>
{
"accountId": <account_id>,
"rules": [
{
"country": "US", // currently only US is supported, may be omitted
"locationId": 21167,
"useGlobalRate": true,
"shippingTaxed": false
},
{
"locationId": 21137,
"useGlobalRate": false,
"shippingTaxed": true,
"ratePercent": "2.15"
}
// ...
]
}
注意:运输公司费率仅适用于美国、德国和澳大利亚。目前,美国和澳大利亚支持营业地点组。
复杂的配送规则:二维表和子表
要在美国定义 7 美元的运费促销活动,在纽约市为重量超过 10 磅的订单定义 3 美元或 5 美元的运费促销(具体取决于订单的价格),以及低于该重量的订单免运费,请使用以下内容:
PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
"accountId": <account_id>,
"services": [
{
"name": "Custom shipping rules",
"deliveryCountry": "US",
"rateGroups": [
{
"mainTable": {
"rowHeaders": {
"postalCodeGroupNames": [ "NYC", "all other locations" ]
},
"columnHeaders": {
"weights": [
{ "unit": "lb", "value": "10" },
{ "unit": "lb", "value": "infinity" }
]
},
"rows": [
{
"cells": [
{ "flatRate": { "value": "0", "currency": "USD" } },
{ "subtableName": "NYC large packages" }
]
},
{
"cells": [
{ "flatRate": { "value": "7", "currency": "USD" } },
{ "flatRate": { "value": "7", "currency": "USD" } }
]
}
]
},
"subtables": [
{
"name": "NYC large packages",
"rowHeaders": {
"prices": [
{"value": "100", "currency": "USD"},
{"value": "infinity", "currency": "USD"}]
},
"rows": [
{
"cells": [
{ "flatRate": { "value": "3", "currency": "USD" } }
]
},
{
"cells": [
{ "flatRate": { "value": "5", "currency": "USD" } }
]
}
]
}
]
}
],
"active": true,
"currency": "USD",
"deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
}
],
"postalCodeGroups": [
{
"name": "NYC", // Approximation of NYC using postal codes
"country": "US",
"postalCodeRanges": [
{ "postalCodeRangeBegin": "10000", postalCodeRangeEnd: "11999" }
]
}
]
}
复杂的配送规则:按服务拆分配送标签
在 shippingsettings 中,每项配送服务最多只能包含 20 个 运费组。由于使用运费组来区分 这似乎表明 单独配送费率可通过配送标签强制实施。不过,您可以 在每个国家/地区最多提供 20 项配送服务。按拆分速率 通过配送标签区分同一国家/地区的多项服务, 您最多可以通过配送标签区分 400 种不同的配送费率。
注意:如果您有多项服务,则每项 我们会对照指定国家/地区的所有配送服务对其进行检查 计算可能的运费。如果返回多项服务 为同一商品指定不同的费率,系统将使用最低费率。
以下示例将 40 个使用唯一费率的配送标签拆分为两组 不同服务此示例隐藏了其他配送详情 资源(如实际费率)包含在省略号后面。
PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
"accountId": <account_id>,
"services": [
{
"name": "labels_0_19",
"deliveryCountry": "US",
"active": true,
"currency": "USD",
"deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
"rateGroups": [
{ "applicableShippingLabels": ["shipping_label_0"], ... }
{ "applicableShippingLabels": ["shipping_label_1"], ... }
{ "applicableShippingLabels": ["shipping_label_2"], ... }
{ "applicableShippingLabels": ["shipping_label_3"], ... }
{ "applicableShippingLabels": ["shipping_label_4"], ... }
{ "applicableShippingLabels": ["shipping_label_5"], ... }
{ "applicableShippingLabels": ["shipping_label_6"], ... }
{ "applicableShippingLabels": ["shipping_label_7"], ... }
{ "applicableShippingLabels": ["shipping_label_8"], ... }
{ "applicableShippingLabels": ["shipping_label_9"], ... }
{ "applicableShippingLabels": ["shipping_label_10"], ... }
{ "applicableShippingLabels": ["shipping_label_11"], ... }
{ "applicableShippingLabels": ["shipping_label_12"], ... }
{ "applicableShippingLabels": ["shipping_label_13"], ... }
{ "applicableShippingLabels": ["shipping_label_14"], ... }
{ "applicableShippingLabels": ["shipping_label_15"], ... }
{ "applicableShippingLabels": ["shipping_label_16"], ... }
{ "applicableShippingLabels": ["shipping_label_17"], ... }
{ "applicableShippingLabels": ["shipping_label_18"], ... }
{ "applicableShippingLabels": ["shipping_label_19"], ... }
]
},
{
"name": "labels_20_39",
"deliveryCountry": "US",
"active": true,
"currency": "USD",
"deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
"rateGroups": [
{ "applicableShippingLabels": ["shipping_label_20"], ... }
{ "applicableShippingLabels": ["shipping_label_21"], ... }
{ "applicableShippingLabels": ["shipping_label_22"], ... }
{ "applicableShippingLabels": ["shipping_label_23"], ... }
{ "applicableShippingLabels": ["shipping_label_24"], ... }
{ "applicableShippingLabels": ["shipping_label_25"], ... }
{ "applicableShippingLabels": ["shipping_label_26"], ... }
{ "applicableShippingLabels": ["shipping_label_27"], ... }
{ "applicableShippingLabels": ["shipping_label_28"], ... }
{ "applicableShippingLabels": ["shipping_label_29"], ... }
{ "applicableShippingLabels": ["shipping_label_30"], ... }
{ "applicableShippingLabels": ["shipping_label_31"], ... }
{ "applicableShippingLabels": ["shipping_label_32"], ... }
{ "applicableShippingLabels": ["shipping_label_33"], ... }
{ "applicableShippingLabels": ["shipping_label_34"], ... }
{ "applicableShippingLabels": ["shipping_label_35"], ... }
{ "applicableShippingLabels": ["shipping_label_36"], ... }
{ "applicableShippingLabels": ["shipping_label_37"], ... }
{ "applicableShippingLabels": ["shipping_label_38"], ... }
{ "applicableShippingLabels": ["shipping_label_39"], ... }
]
}
],
"postalCodeGroups": [ ... ]
}
可能还需要跨费率组拆分配送标签
即使这些配送标签共用相同的配送费率,因为每个费率
组内只能有 30 个配送标签,
applicableShippingLabels
字段。举一个极端的例子
如果所有配送标签具有相同的费率结构,
shippingsettings
最多可处理
单个国家/地区 12,000 个配送标签:每个费率 30 个配送标签
组,每项配送服务 20 个费率组,每项配送服务 20 个
国家/地区。
如需了解详情,请参阅 accounttax 和 shippingsettings 参考文档。