運送設定總覽

shippingsettings 資源可讓您擷取及更新帳戶的運送設定。

Google 可以自動更新部分產品的預估送達時間。詳情請參閱「啟用自動改善」。

讀取、撰寫或更新運送設定

如要使用 Merchant API 運送服務,請按照下列步驟操作:

  1. 提出 GET 要求,擷取帳戶的完整運送設定。
  2. 修改運送設定。
  3. 使用修改後的運送設定提出 INSERT 要求。

ETag

Etag 是一種編碼權杖,可用於避免非同步更新。如有任何運送設定資料變更, eTag 也會隨之改變使用者必須將透過 GET 要求取得的 etag,複製到 INSERT 要求主體。

如果運送設定資料在 GET 要求與 INSERT 要求之間發生變更,您會收到錯誤訊息,要求再次 GET 要求擷取最新的 ETag 權杖。您必須呼叫 GET 要求以擷取新的 ETag 權杖,並將新的 etag 權杖複製到 INSERT 要求主體。

新增運送設定

使用 shippingsettings.insert 新增或更新帳戶的運送設定。下列範例要求將帳戶 10 之下名為「GSA Shipping - Free Ship Over $49.99」的運送服務的 maxTransitDays 更新為 7。

POST https://merchantapi.googleapis.com/accounts/v1beta/accounts/{accountId}/shippingSettings/

{
  "services": [
    {
      "name": "FedEx",
      "active": true,
      "deliveryCountries": ["US"],
      "currencyCode": "USD",
      "deliveryTime": {
        "minTransitDays": 4,
        "maxTransitDays": 6,
        "minHandlingDays": 0,
        "maxHandlingDays": 0
      },
      "rateGroups": [
        {
          "singleValue": {
            "flatRate": {
              "amountMicros": 5990000,
              "currencyCode": "USD"
            }
          },
          "name": "All products"
        }
      ]
    },
    {
      "name": "GSA Shipping - Free Ship Over $49.99",
      "active": true,
      "deliveryCountries": "US",
      "currencyCode": "USD",
      "deliveryTime": {
        "minTransitDays": 3,
        "maxTransitDays": 7,
        "minHandlingDays": 1,
        "maxHandlingDays": 2
      },
      "rateGroups": [
        {
          "mainTable": {
            "rowHeaders": {
              "prices": [
                {
                  "amountMicros": 49990000,
                  "currencyCode": "USD"
                },
                {
                  "amountMicros": -1,
                  "currencyCode": "USD"
                }
              ]
            },
            "rows": [
              {
                "cells": [
                  {
                    "flatRate": {
                      "amountMicros": 6990000,
                      "currencyCode": "USD"
                    }
                  }
                ]
              },
              {
                "cells": [
                  {
                    "flatRate": {
                      "amountMicros": 0,
                      "currencyCode": "USD"
                    }
                  }
                ]
              }
            ]
          },
          "name": "Free Ship Over $49.99"
        }
      ]
    }
  ]
}

設定倉儲

以下 JSON 範例說明如何使用商家運送設定服務,管理商家帳戶的倉儲資訊:

"warehouses": [
  {
    "name": "warehouse 1",
    "shippingAddress": {
      "streetAddress": {street_address},
      "city": {city},
      "administrativeArea": {administrative_area},
      "postalCode": {postal_code},
      "regionCode": {region_code}
    },
    "cutoffTime": {
      "minutes": {minutes}
    },
    "handlingDays": {handling_days},
    "businessDaysConfig": {
      "businessDays": [
        "MONDAY", "SUNDAY"
      ]
    }
  }
]

更改下列內容:

  • {street_address}:倉庫地址的街道部分。
  • {city}:倉儲所在的城市、鄉鎮或市鎮。
  • {administrative_area}:國家/地區的行政劃分。例如,州/省行政區。
  • {postal_code}:郵遞區號。
  • {region_code}:字串中的國家/地區代碼。
  • {minutes}:截止時間的分鐘數,是訂單必須在該訂單下單的同一天進行處理。
  • {handling_days}:這個倉庫需要多少天才會寄出及運送商品。

warehouses 資源是倉儲清單。每個倉庫都可以透過 warehouse.name 以運送服務的倉庫運送時間參照。

管理倉儲

以下說明如何使用 Merchant API 管理倉儲:

  1. 發出 GET 要求以擷取所有現有的 shippingsettings 和倉儲。
  2. GET 要求中的 shippingsettings 複製到 UPDATE 要求。

  3. 如要在 INSERT 要求的 warehouses 區段中使用倉儲,請填入倉儲。

  4. 發出包含 shippingsettingswarehouses 資源的 UPDATE 要求。

以下 INSERT 要求主體範例已從紐約更新為倉庫 1

{
  "services": [
    {
      "name": "Standard Shipping",
      "active": true,
      "deliveryCountries": ["US", "UK"],
      "currencyCode": "USD",
      "deliveryTime": {
        "minHandlingDays": 0,
        "maxHandlingDays": 1,
        "warehouseBasedDeliveryTimes": [
{"carrier": "Fedex"
 "carrierService": "ground"
 "warehouse": "Warehouse 1"
},
{"carrier": "Fedex"
 "carrierService": "2 days"
 "warehouse": "Warehouse 2"
}
]
      },
      "rateGroups": [
        {
          "singleValue": {
            "flatRate": {
              "amountMicros": 0,
              "currencyCode": "USD"
            }
          },
          "name": "Standard Shipping"
        }
      ],
    },
    {
      "name": "Expedited",
            "flatRate": {
              "amountMicros": 9990000,
              "currencyCode": "USD"
            }
          },
          "name": "Expedited"
        }
      ],
    }
  ],
  "warehouses": [
    {
      "name": "Warehouse1",
      "shippingAddress": [
        {
        "streetAddress": "1111 shoreline street"
          "city": "Mountain View",
          "administrativeArea": "CA"
        }
      ]
    },
    {
      "name": "Warehouse 2",
      "country": "US",
      "postalCodeRanges": [
        {
        "streetAddress": "1111 5th avenue"
          "city": "New York",
          "administrativeArea": "NY"
        }
      ]
    }
  ]
}

新增當天到貨服務

如果您有店面商品目錄資料,可以使用 Content API for Shopping 設定當天到貨運送服務。當天到貨運送服務的 shipment_typelocal_delivery。目前所有 local_delivery 運送服務都將視為當天到貨。

您無法變更店面配送服務的delivery_time資訊。使用 shippingsettings.insert 為店面商品目錄產品設定當天到貨服務。

以下要求主體範例會為帳戶的所有商店新增當天到貨服務:

{
  "name": "accounts/accountId/shippingSettings",
  "services": [
    {
      "name": "Local Delivery",
      "active": true,
      "shipmentType": "local_delivery",
      "deliveryCountries": "US",
      "currencyCode": "USD",
      "rateGroups": [
        {
          "singleValue": {
            "flatRate": {
              "amountMicros": 0,
              "currencyCode": "USD"
            }
          }
        }
      ],
      "storeConfig": {
        "storeServiceType": "all stores",
        "storeCodes": [],
        "cutoffConfig": {
          "storeCloseOffsetHours": 2,
          "noDeliveryPostCutoff": true
        },
        "serviceRadius": {
          "value": 4,
          "unit": "Miles"
        }
      }
    }
  ]
}

新增次日到貨服務

根據預設,當天到貨截止時間之後下的訂單會排入次日到貨。如要關閉次日到貨服務,請將 no_delivery_post_cutoff 欄位設為 true。如果您停用次日到貨服務,運送服務就只會在每天截止時間前顯示。

只有在 shipment_typelocal_delivery 時,才能到次日到貨。