送料設定の概要

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

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