The ShippingSettings resource lets you retrieve and update the shipping settings of your account.
Google can update the estimated delivery time for some products automatically. For more information, see Enable automatic improvements .
Чтение, запись или обновление настроек доставки.
To use the Merchant API shipping service, do the following:
- Make a
GETrequest to retrieve the complete shipping settings of your account. - Измените настройки доставки.
- Создайте запрос
INSERTс измененными настройками доставки.
Этаг
Etag — это закодированный токен, предназначенный для предотвращения асинхронных обновлений. Etag изменяется при изменении любых данных в настройках доставки. Пользователям необходимо скопировать полученный из GET запроса Etag в тело INSERT запроса.
Если данные настроек доставки изменяются между запросом GET и запросом INSERT , вы получите сообщение об ошибке, требующее повторного запроса GET для получения самого последнего токена etag. Вам необходимо вызвать запрос GET для получения нового токена etag и скопировать новый токен etag в тело запроса INSERT .
Добавьте настройки доставки.
Используйте shippingsettings.insert для добавления или обновления настроек доставки для вашей учетной записи. Вот пример запроса, который обновляет значение maxTransitDays до 7 для службы доставки GSA Shipping - Free Ship Over $49.99 , в учетной записи 10.
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"
}
]
}
]
}
Here's a sample you can use to insert a shipping setting:
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 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} : Street-level part of the warehouse's address.
- {city} : Город, поселок или коммуна, где расположен склад.
- {administrative_area} : The administrative subdivision of the country. For example, a state.
- {postal_code} : Почтовый индекс или ZIP-код.
- {region_code} : Код страны в виде строки.
- {minutes} : Минуты — часть крайнего срока, до которого необходимо разместить заказ, чтобы он был обработан складом в тот же день.
- {handling_days} : The number of days it takes for this warehouse to pack and ship an item.
The warehouses resource is a list of warehouses. Each warehouse can be referred by shipping service's warehouse-based delivery time through warehouse.name .
Управляйте своими складами
Here's how to use the Merchant API to manage your warehouses:
- Make a
GETrequest to retrieve all your existingshippingsettingsand warehouses. Copy the
shippingsettingsfrom theGETrequest to theUPDATErequest.Укажите склады, если вы хотите использовать их в разделе
warehousesдля запросаINSERT.Make an
UPDATErequest that containsshippingsettingsandwarehousesresources.
Here's a sample INSERT request body with warehouse for Warehouse 1 updated from New York to Mountain View:
{
"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 для покупок, чтобы настроить доставку в тот же день, если у вас есть локальный склад. Для доставки в тот же день shipment_type — local_delivery . В настоящее время все отправления с типом отправления local_delivery считаются доставкой в тот же день.
You can't change the delivery_time information for local deliveries. Use shippingsettings.insert to set up same day delivery for your local inventory products.
Вот пример текста запроса, который добавляет услугу доставки в тот же день во все магазины для вашей учетной записи:
{
"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_type указан как local_delivery .
Узнать больше
Чтобы узнать о миграции с Content API for Shopping, см. раздел «Миграция управления настройками доставки» .