帳戶層級稅金和運費

透過 Content API,您可以透過 shippingsettingsaccounttax 服務來指定要套用至帳戶中的所有產品所收取的稅金和運費。如需更精確的資訊,您可以透過 products 服務,在商品層級指定稅金和運費。

如要瞭解 Google 政策,以及指定稅金和運費的完整方案,請參閱下列說明中心文章:

請注意,tax 屬性和使用 accounttax 服務,僅適用於指定美國為目標的產品。

帳戶稅金和運送設定 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 的 accounttaxshippingsettings 服務提出要求。請先調整運送設定:

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 美元的貨貨,以 30 英鎊的等效,具備訂購的貨物,為低免重量,使用以下:

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 筆不重複的運送費率。

注意:如果您有多項服務,系統會針對該國家/地區的所有運送服務檢查該國家/地區的每項產品,並計算出可能的運費。如有多項產品傳回同一項產品的不同費率,系統會採用最低費率。

以下範例將 20 個運費標籤以不同的費率拆分成兩項不同的服務。這個範例會隱藏刪節號的其他運送詳細資料,例如實際費率。

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": [ ... ]
}

此外,即使運送標籤共用相同的運送費率,也可能需要在不同費率群組中拆分運費標籤,因為每個費率群組在 applicableShippingLabels 欄位中只能有 30 個運送標籤。舉例來說,如果所有運送標籤的費率結構相同,shippingsettings 可以在單一國家/地區處理最多 12000 個運送標籤:每個費率群組 30 個運送標籤,每項運送服務 20 個費率群組,以及每個國家/地區 20 個運送服務。

詳情請參閱 accounttaxshippingsettings 的參考說明文件。