送料設定の概要

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/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_type として local_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 からの移行については、配送設定の管理を移行するをご覧ください。