透過 Content API,您可以使用運送設定和帳戶稅服務,指定帳戶中所有產品的稅金和運費。如要更精準地設定,可以透過 products 服務,為商品設定稅金和運費。
如要瞭解 Google 政策,以及各種稅金和運送選項相關資訊,請參閱下列說明中心文章:
請注意,tax
屬性和因此使用 Accounttax 服務的情況,僅適用於指定美國的產品。
Accounttax 和 shippingsettings Content API 服務,其功能與 Merchant Center UI 的功能相同。
簡易範例
如果運費為法國地區為 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"
}
// ...
]
}
注意:貨運公司費率僅適用於美國、德國和澳洲。地區群組目前適用於美國和澳洲。
複雜運送規則:2D 表格和子表格
如要在美國定義運送促銷活動的促銷活動為 $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" }
]
}
]
}
複雜的運送規則:將運送標籤拆分至各項服務
在運送設定中,每項運送服務最多只能包含 20 個 運送費率群組。由於運送費率群組是用於區分 顯示運送標籤的運費,但這個建議可能僅建議指出 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 個運送服務
國家。