送料設定の概要

ShippingSettings リソースを使用すると、アカウントの配送設定を取得して更新できます。

一部の商品については、Google が自動的にお届け予定日を更新することがあります。詳細については、自動改善を有効にするをご覧ください。

配送設定の読み取り、書き込み、更新

Merchant API 配送サービスを利用する手順は次のとおりです。

  1. GET リクエストを送信して、アカウントの配送設定をすべて取得します。
  2. 配送設定を変更します。
  3. 変更した配送設定を使用して INSERT リクエストを行います。

etag

Etag は、非同期更新を回避するためのエンコードされたトークンです。配送設定データが変更されると、etag が変更されます。ユーザーは、GET リクエストから取得した etag を INSERT リクエスト本文にコピーする必要があります。

GET リクエストと INSERT リクエストの間で配送設定データが変更された場合、最新の ETag トークンを取得するための別の GET リクエストをリクエストするエラー メッセージが表示されます。GET リクエストを呼び出して新しい etag トークンを取得し、新しい etag トークンを INSERT リクエスト本文にコピーする必要があります。

配送設定を追加する

shippingsettings.insert を使用して、アカウントの配送設定を追加または更新します。アカウント 10 の配送サービス「GSA Shipping - Free Ship Over $49.99」の maxTransitDays を 7 に更新するリクエストの例を次に示します。

POST https://merchantapi.googleapis.com/accounts/v1/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"
        }
      ]
    }
  ]
}

配送設定を挿入するために使用できるサンプルを次に示します。

Python

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import GetShippingSettingsRequest
from google.shopping.merchant_accounts_v1 import ShippingSettingsServiceClient

_ACCOUNT = configuration.Configuration().read_merchant_info()
_PARENT = f"accounts/{_ACCOUNT}"


def get_shipping_settings():
  """Gets the ShippingSettings for a given Merchant Center account."""

  # Gets OAuth Credentials.
  credentials = generate_user_credentials.main()

  # Creates a client.
  client = ShippingSettingsServiceClient(credentials=credentials)

  # Creates the Shipping Settings name
  name = _PARENT + "/shippingSettings"

  # Creates the request.
  request = GetShippingSettingsRequest(name=name)

  # Makes the request and prints the retrieved ShippingSettings.
  try:
    response = client.get_shipping_settings(request=request)
    print("Retrieved ShippingSettings below")
    print(response)
  except RuntimeError as e:
    print(e)


if __name__ == "__main__":
  get_shipping_settings()

倉庫を設定する

次の JSON サンプルは、Merchant Shipping 設定サービスを使用して Merchant Center アカウントの倉庫情報を管理する方法を示しています。

"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 リクエストから UPDATE リクエストに shippingsettings をコピーします。

  3. INSERT リクエストの warehouses セクションで倉庫を使用する場合は、倉庫を入力します。

  4. shippingsettings リソースと warehouses リソースを含む UPDATE リクエストを送信します。

Warehouse 1 の倉庫がニューヨークからマウンテンビューに更新された INSERT リクエスト本文の例を次に示します。

{
  "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 の場合にのみ利用できます。

その他の情報

Content API for Shopping からの移行については、配送設定の管理を移行するをご覧ください。