Sử dụng API phụ Tài khoản để quản lý chế độ cài đặt thông tin vận chuyển cho tất cả sản phẩm trong tài khoản và tất cả tài khoản phụ được liên kết.
Những thay đổi mà bạn thực hiện đối với chế độ cài đặt thông tin vận chuyển sẽ áp dụng cho tất cả sản phẩm. Để cập nhật thông tin vận chuyển cho từng sản phẩm, hãy sử dụng Merchant Products API.
Để biết thêm thông tin, hãy xem bài viết Thiết lập chế độ cài đặt thông tin vận chuyển.
Tổng quan về chế độ cài đặt thông tin vận chuyển
Tài nguyên accounts.shippingSettings
cho phép bạn truy xuất và cập nhật chế độ cài đặt thông tin vận chuyển của tài khoản nâng cao và tất cả các tài khoản phụ được liên kết.
Các đơn vị tích hợp, đơn vị tổng hợp và đối tác kênh thường sử dụng tài khoản nâng cao để quản lý cửa hàng trực tuyến và dịch vụ API cho nhiều doanh nghiệp. Những doanh nghiệp có nhiều cửa hàng trực tuyến hoặc thương hiệu được bán trên các trang web riêng biệt cũng có thể chọn sử dụng tài khoản phụ trong một tài khoản nâng cao duy nhất.
Google có thể tự động cập nhật thời gian giao hàng dự kiến cho một số sản phẩm.
Thêm chế độ cài đặt thông tin vận chuyển
Để thêm hoặc cập nhật chế độ cài đặt thông tin vận chuyển cho tài khoản của bạn, hãy sử dụng phương thức accounts.shippingSettings.insert
.
Yêu cầu mẫu sau đây đặt giá vận chuyển, chương trình khách hàng thân thiết mà dịch vụ vận chuyển này bị giới hạn và mã đơn vị tiền tệ.
HTTP
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings:insert
{
"etag": "",
"name": "accounts/ACCOUNT_ID/shippingSetting",
"services": [
{
"deliveryCountries": [
"COUNTRY_CODE"
],
"serviceName": "SERVICE_NAME",
"active": false,
"deliveryTime": {},
"loyaltyPrograms": [
{
"programLabel": "PROGRAM_LABEL"
}
],
"minimumOrderValue": {
"amountMicros": PRICE,
"currencyCode": "CURRENCY_CODE"
},
"currencyCode": "USD",
"rateGroups": [
{
"applicableShippingLabels": [
"SHIPPING_LABEL"
],
"singleValue": {
"flatRate": {
"amountMicros": 10000000,
"currencyCode": "USD"
}
}
}
]
}
]
}
cURL
curl --request POST \
'https://merchantapi.googleapis.com/accounts/v1/accounts/ACCOUNT_ID/shippingSettings:insert' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"name":"SHIPPING_SETTING_NAME","services":[{"serviceName":"SERVICE_NAME","currencyCode":"CURRENCY_CODE","rateGroups":[{"applicableShippingLabels":["SHIPPING_LABEL"],"carrierRates":[{"name":"new","carrier":"CARRIER_NAME","carrierService":"CARRIER_SERVICE","originPostalCode":"ZIPCODE"}],"singleValue":{"flatRate":{"amountMicros":10000000,"currencyCode":"USD"}}}],"deliveryCountries":["COUNTRY_CODE"],"deliveryTime":{"maxHandlingDays":2,"minHandlingDays":1},"minimumOrderValue":{"amountMicros":50000000,"currencyCode":"USD"},"active":false}]}' \
--compressed
Thay thế nội dung sau:
- ACCOUNT_ID: Giá trị nhận dạng duy nhất của tài khoản Merchant Center.
- COUNTRY_CODE: Mã CLDR (Kho dữ liệu chung về ngôn ngữ) của quốc gia mà dịch vụ này áp dụng. Phải khớp với giá trong nhóm giá.
- SERVICE_NAME: Tên của dịch vụ.
- CARRIER_NAME: Tên của hãng vận chuyển. Ví dụ: UPS và Fedex.
- CARRIER_SERVICE: Dịch vụ được hỗ trợ của hãng vận chuyển.
Để xem danh sách đầy đủ các dịch vụ của hãng vận chuyển, hãy xem Mức phí của hãng vận chuyển (chỉ áp dụng cho Úc, Đức, Vương quốc Anh và Hoa Kỳ).
- PROGRAM_LABEL: Nhãn chương trình khách hàng thân thiết được đặt trong chế độ cài đặt chương trình khách hàng thân thiết của bạn trong Merchant Center.
- SHIPPING_LABEL: Danh sách nhãn vận chuyển xác định những sản phẩm mà nhóm mức phí này áp dụng.
- PRICE: Giá được biểu thị dưới dạng một số bằng micro. Ví dụ: 1 USD = 1.000.000 micros.
- CURRENCY_CODE: Đơn vị tiền tệ của giá bằng cách sử dụng từ viết tắt gồm 3 chữ cái.
Để biết thêm thông tin về các trường được chỉ định, hãy xem tài liệu tham khảo.
Nội dung yêu cầu phải chứa toàn bộ nội dung tài nguyên của tài nguyên accounts.shippingSettings
, ngay cả khi bạn chỉ cập nhật một thuộc tính duy nhất, vì mọi giá trị NULL hoặc giá trị bị thiếu trong nội dung yêu cầu sẽ dẫn đến việc vô hiệu hoá các giá trị hiện có.
Sau đây là một phản hồi mẫu từ một lệnh gọi thành công:
{
"name": "accounts/ACCOUNT_ID/shippingSettings",
"services": [
{
"serviceName": "SERVICE_NAME",
"active": false,
"deliveryCountries": [
"COUNTRY_CODE"
],
"currencyCode": "CURRENCY_CODE",
"rateGroups": [
{
"applicableShippingLabels": [
"SHIPPING_LABEL"
],
"singleValue": {
"flatRate": {
"amountMicros": "PRICE",
"currencyCode": "CURRENCY_CODE"
}
}
}
],
"shipmentType": "LOCAL_DELIVERY",
"storeConfig": {
"storeServiceType": "ALL_STORES",
"cutoffConfig": {
"localCutoffTime": {
"hour": "7",
"minute": "40"
},
"noDeliveryPostCutoff": false
},
"serviceRadius": {
"value": "40",
"unit": "KILOMETERS"
}
}
}
],
"etag": "OAJCTQgBEAAaRwoEdGVzdBIEIgJVUxoDVVNEIggiBggHECgoACoeCAESDwoNCAESCU9WRVJTSVpFRBoJIgcIAhCAwtcvWAWSAQCaAQQIAhAo"
}
Sau đây là mẫu bạn có thể dùng để cập nhật chế độ cài đặt thông tin vận chuyển cho một tài khoản nhất định bằng thư viện ứng dụng:
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.DeliveryTime;
import com.google.shopping.merchant.accounts.v1.InsertShippingSettingsRequest;
import com.google.shopping.merchant.accounts.v1.RateGroup;
import com.google.shopping.merchant.accounts.v1.Service;
import com.google.shopping.merchant.accounts.v1.Service.ShipmentType;
import com.google.shopping.merchant.accounts.v1.ShippingSettings;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.Value;
import com.google.shopping.type.Price;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to insert a ShippingSettings for a Merchant Center account. */
public class InsertShippingSettingsSample {
private static String getParent(String accountId) {
return String.format("accounts/%s", accountId);
}
public static void insertShippingSettings(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
ShippingSettingsServiceSettings shippingSettingsServiceSettings =
ShippingSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates parent to identify where to insert the shippingsettings.
String parent = getParent(config.getAccountId().toString());
// Calls the API and catches and prints any network failures/errors.
try (ShippingSettingsServiceClient shippingSettingsServiceClient =
ShippingSettingsServiceClient.create(shippingSettingsServiceSettings)) {
InsertShippingSettingsRequest request =
InsertShippingSettingsRequest.newBuilder()
.setParent(parent)
.setShippingSetting(
ShippingSettings.newBuilder()
// Etag needs to be an empty string on initial insert
// On future inserts, call GET first to get the Etag
// Then use the retrieved Etag on future inserts.
// NOTE THAT ON THE INITIAL INSERT, YOUR SHIPPING SETTINGS WILL
// NOT BE STORED, YOU HAVE TO CALL INSERT AGAIN WITH YOUR
// RETRIEVED ETAG.
// .setEtag("")
.setEtag("PPa=")
.addServices(
Service.newBuilder()
.setServiceName("Canadian Postal Service")
.setActive(true)
.addDeliveryCountries("CA")
.setCurrencyCode("CAD")
.setDeliveryTime(
DeliveryTime.newBuilder()
.setMinTransitDays(0)
.setMaxTransitDays(3)
.setMinHandlingDays(0)
.setMaxHandlingDays(3)
.build())
.addRateGroups(
RateGroup.newBuilder()
.addApplicableShippingLabels("Oversized")
.addApplicableShippingLabels("Perishable")
.setSingleValue(Value.newBuilder().setPricePercentage("5.4"))
.setName("Oversized and Perishable items")
.build())
.setShipmentType(ShipmentType.DELIVERY)
.setMinimumOrderValue(
Price.newBuilder()
.setAmountMicros(10000000)
.setCurrencyCode("CAD")
.build())
.build())
.build())
.build();
System.out.println("Sending insert ShippingSettings request");
ShippingSettings response = shippingSettingsServiceClient.insertShippingSettings(request);
System.out.println("Inserted ShippingSettings Name below");
System.out.println(response.getName());
// You can apply ShippingSettings to specific products by using the `shippingLabel` field
// on the product.
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
insertShippingSettings(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\ShippingSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\DeliveryTime;
use Google\Shopping\Merchant\Accounts\V1\InsertShippingSettingsRequest;
use Google\Shopping\Merchant\Accounts\V1\RateGroup;
use Google\Shopping\Merchant\Accounts\V1\Service;
use Google\Shopping\Merchant\Accounts\V1\Service\ShipmentType;
use Google\Shopping\Merchant\Accounts\V1\ShippingSettings;
use Google\Shopping\Merchant\Accounts\V1\Value;
use Google\Shopping\Type\Price;
/**
* This class demonstrates how to insert a ShippingSettings for a Merchant Center account.
*/
class InsertShippingSettings
{
/**
* A helper function to create the parent string.
*
* @param string $accountId The account ID.
* @return string The parent in the format "accounts/{accountId}".
*/
private static function getParent(string $accountId): string
{
return sprintf("accounts/%s", $accountId);
}
/**
* Inserts shipping settings for the specified Merchant Center account.
*
* @param array $config The configuration data containing the account ID.
* @return void
*/
public static function insertShippingSettings($config)
{
// Gets the OAuth credentials to make the request.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates options config containing credentials for the client to use.
$options = ['credentials' => $credentials];
// Creates a client.
$shippingSettingsServiceClient = new ShippingSettingsServiceClient($options);
// Creates parent to identify where to insert the shippingsettings.
$parent = self::getParent($config['accountId']);
// Calls the API and catches and prints any network failures/errors.
try {
$request = (new InsertShippingSettingsRequest())
->setParent($parent)
->setShippingSetting(
(new ShippingSettings())
// Etag needs to be an empty string on initial insert
// On future inserts, call GET first to get the Etag
// Then use the retrieved Etag on future inserts.
// NOTE THAT ON THE INITIAL INSERT, YOUR SHIPPING SETTINGS WILL
// NOT BE STORED, YOU HAVE TO CALL INSERT AGAIN WITH YOUR
// RETRIEVED ETAG.
->setEtag("")
->setServices([
(new Service())
->setServiceName("Canadian Postal Service")
->setActive(true)
->setDeliveryCountries(["CA"])
->setCurrencyCode("CAD")
->setDeliveryTime(
(new DeliveryTime())
->setMinTransitDays(0)
->setMaxTransitDays(3)
->setMinHandlingDays(0)
->setMaxHandlingDays(3)
)
->setRateGroups(
[(new RateGroup())
->setApplicableShippingLabels(["Oversized","Perishable"])
->setSingleValue((new Value())->setPricePercentage("5.4"))
->setName("Oversized and Perishable items")]
)
->setShipmentType(ShipmentType::DELIVERY)
->setMinimumOrderValue(
(new Price())
->setAmountMicros(10000000)
->setCurrencyCode("CAD")
)
])
);
print "Sending insert ShippingSettings request" . PHP_EOL;
$response = $shippingSettingsServiceClient->insertShippingSettings($request);
print "Inserted ShippingSettings below" . PHP_EOL;
print_r($response);
// You can apply ShippingSettings to specific products by using the `shippingLabel` field
// on the product.
} catch (ApiException $e) {
print $e->getMessage();
}
}
/**
* Helper to execute the sample.
*
* @return void
*/
public function callSample(): void
{
$config = Config::generateConfig();
// Makes the call to insert shipping settings for the MC account.
self::insertShippingSettings($config);
}
}
// Run the script
$sample = new InsertShippingSettings();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import DeliveryTime
from google.shopping.merchant_accounts_v1 import InsertShippingSettingsRequest
from google.shopping.merchant_accounts_v1 import RateGroup
from google.shopping.merchant_accounts_v1 import Service
from google.shopping.merchant_accounts_v1 import ShippingSettings
from google.shopping.merchant_accounts_v1 import ShippingSettingsServiceClient
from google.shopping.merchant_accounts_v1 import Value
_ACCOUNT = configuration.Configuration().read_merchant_info()
_PARENT = f"accounts/{_ACCOUNT}"
def insert_shipping_settings():
"""Inserts a ShippingSettings for a Merchant Center account."""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = ShippingSettingsServiceClient(credentials=credentials)
# Creates the request.
request = InsertShippingSettingsRequest(
parent=_PARENT,
shipping_setting=ShippingSettings(
# Etag needs to be an empty string on initial insert
# On future inserts, call GET first to get the Etag
# Then use the retrieved Etag on future inserts.
# NOTE THAT ON THE INITIAL INSERT, YOUR SHIPPING SETTINGS WILL
# NOT BE STORED, YOU HAVE TO CALL INSERT AGAIN WITH YOUR
# RETRIEVED ETAG.
etag="",
services=[
Service(
service_name="Canadian Postal Service",
active=True,
delivery_countries=["CA"],
currency_code="CAD",
delivery_time=DeliveryTime(
min_transit_days=0,
max_transit_days=3,
min_handling_days=0,
max_handling_days=3,
),
rate_groups=[
RateGroup(
applicable_shipping_labels=[
"Oversized",
"Perishable",
],
single_value=Value(price_percentage="5.4"),
name="Oversized and Perishable items",
)
],
shipment_type=Service.ShipmentType.DELIVERY,
minimum_order_value={
"amount_micros": 10000000,
"currency_code": "CAD",
},
)
],
),
)
# Makes the request and prints the inserted ShippingSettings name.
try:
response = client.insert_shipping_settings(request=request)
print("Inserted ShippingSettings below")
print(response)
# You can apply ShippingSettings to specific products by using the
# `shippingLabel` field on the product.
except RuntimeError as e:
print(e)
if __name__ == "__main__":
insert_shipping_settings()
Truy xuất chế độ cài đặt thông tin vận chuyển
Các yêu cầu sau đây cho biết cách bạn có thể truy xuất chế độ cài đặt thông tin vận chuyển của một tài khoản Merchant Center:
HTTP
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings
cURL
curl \
'https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Sau đây là một mẫu mà bạn có thể dùng để truy xuất thông tin về chế độ cài đặt thông tin vận chuyển cho một tài khoản nhất định bằng cách sử dụng thư viện ứng dụng:
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.GetShippingSettingsRequest;
import com.google.shopping.merchant.accounts.v1.ShippingSettings;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsName;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to get the ShippingSettings for a given Merchant Center account. */
public class GetShippingSettingsSample {
public static void getShippingSettings(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
ShippingSettingsServiceSettings shippingSettingsServiceSettings =
ShippingSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates ShippingSettings name to identify ShippingSettings.
String name =
ShippingSettingsName.newBuilder()
.setAccount(config.getAccountId().toString())
.build()
.toString();
// Calls the API and catches and prints any network failures/errors.
try (ShippingSettingsServiceClient shippingSettingsServiceClient =
ShippingSettingsServiceClient.create(shippingSettingsServiceSettings)) {
// The name has the format: accounts/{account}/shippingSettings
GetShippingSettingsRequest request =
GetShippingSettingsRequest.newBuilder().setName(name).build();
System.out.println("Sending Get ShippingSettings request:");
ShippingSettings response = shippingSettingsServiceClient.getShippingSettings(request);
System.out.println("Retrieved ShippingSettings below");
System.out.println(response);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
getShippingSettings(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\ShippingSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\GetShippingSettingsRequest;
/**
* This class demonstrates how to get the ShippingSettings for a given Merchant Center account.
*/
class GetShippingSettings
{
/**
* Retrieves the shipping settings for the specified Merchant Center account.
*
* @param array $config The configuration data containing the account ID.
* @return void
*/
public static function getShippingSettings($config)
{
// Gets the OAuth credentials to make the request.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates options config containing credentials for the client to use.
$options = ['credentials' => $credentials];
// Creates a client.
$shippingSettingsServiceClient = new ShippingSettingsServiceClient($options);
// Creates ShippingSettings name to identify ShippingSettings.
// The name has the format: accounts/{account}/shippingSettings
$name = "accounts/" . $config['accountId'] . "/shippingSettings";
// Calls the API and catches and prints any network failures/errors.
try {
$request = (new GetShippingSettingsRequest())
->setName($name);
print "Sending Get ShippingSettings request:" . PHP_EOL;
$response = $shippingSettingsServiceClient->getShippingSettings($request);
print "Retrieved ShippingSettings below" . PHP_EOL;
print_r($response);
} catch (ApiException $e) {
print $e->getMessage();
}
}
/**
* Helper to execute the sample.
*
* @return void
*/
public function callSample(): void
{
$config = Config::generateConfig();
// Makes the call to get shipping settings for the MC account.
self::getShippingSettings($config);
}
}
// Run the script
$sample = new GetShippingSettings();
$sample->callSample();
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()
Thêm chế độ cài đặt kho hàng
Để thêm hoặc cập nhật chế độ cài đặt kho hàng lưu trữ và xử lý kho hàng cho tài khoản của bạn, hãy sử dụng phương thức accounts.shippingSettings.insert
.
Sau đây là cách sử dụng Merchant API để quản lý kho hàng:
Để truy xuất tất cả
shippingsettings
vàwarehouses
hiện có, hãy đưa ra yêu cầuGET
bằng phương thứcaccounts.shippingSettings.getShippingSettings
.Tạo một yêu cầu bằng phương thức
account.shippingSettings.insert
. Sao chép tài nguyênshippingsettings
từ phản hồi của yêu cầuGET
sang yêu cầu chèn.Để thêm thông tin về kho hàng bằng lệnh gọi chèn, hãy điền thông tin chi tiết về kho hàng đó vào tài nguyên
warehouses
trong nội dung yêu cầu.Chạy yêu cầu chèn.
Yêu cầu mẫu sau đây cho biết cách sử dụng phương thức accounts.shippingSettings.insert
để cập nhật chế độ cài đặt kho hàng cho tài khoản của bạn. Yêu cầu này đặt thời gian trong ngày mà đơn đặt hàng có thể được chấp nhận và bắt đầu xử lý, số ngày xử lý và địa chỉ giao hàng.
POST https://merchantapi.googleapis.com/accounts/v1/accounts/ACCOUNT_ID/shippingSettings:insert
{
"etag": "",
"name": "accounts/ACCOUNT_ID/shippingSetting",
"warehouses": [
{
"cutoffTime": {
"hour": 7,
"minute": 50
},
"handlingDays": 7,
"name": "WAREHOUSE_NAME",
"shippingAddress": {
"streetAddress": "ADDRESS",
"administrativeArea": "CA",
"city": "CITY_NAME",
"postalCode": "POSTAL_CODE",
"regionCode": "REGION_CODE"
}
}
]
}
Thay thế nội dung sau:
- ACCOUNT_ID: Giá trị nhận dạng duy nhất của tài khoản Merchant Center.
- WAREHOUSE_NAME: Tên của kho hàng.
- ADDRESS: Địa chỉ giao hàng của kho hàng.
- CITY_NAME: Thành phố, thị trấn hoặc xã. Bạn cũng có thể thêm các địa điểm phụ thuộc hoặc địa điểm phụ. Ví dụ: khu dân cư hoặc vùng ngoại ô.
- POSTAL_CODE: Mã bưu chính hoặc mã ZIP. Ví dụ: 94043.
- REGION_CODE: Mã quốc gia CLDR. Ví dụ: "US".
Sau đây là một phản hồi mẫu từ một lệnh gọi thành công:
{
"name": "accounts/ACCOUNT_ID/shippingSettings",
"warehouses": [
{
"name": "WAREHOUSE_NAME",
"shippingAddress": {
"streetAddress": "ADDRESS",
"city": "CITY_NAME",
"administrativeArea": "CA",
"postalCode": "POSTAL_CODE",
"regionCode": "REGION_CODE"
},
"cutoffTime": {
"hour": 7,
"minute": 50
},
"handlingDays": "7",
"businessDayConfig": {
"businessDays": [
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY"
]
}
}
],
"etag": "OAJiUAjB0au+FBABGgR0ZXN0Ii4KAlVTGgJDQSoKQ2FsaWZvcm5pYWIFOTQwNDNyETExMXcgMzFzdCBTdHJlZXQuKgQIBxAyMAc4ATgCOAM4BDgF"
}
Thiết lập nhóm mã bưu chính
Sử dụng API phụ Tài khoản để quản lý các khu vực (được gọi là postalCodeGroups) cho một tài khoản Merchant Center.
Tài nguyên postalCodeGroups là một danh sách các nhóm, trong đó mỗi nhóm là một danh sách gồm nhiều mã bưu chính có cùng chế độ cài đặt thông tin vận chuyển.
Sử dụng Merchant API để quản lý postalCodeGroups như sau:
Thực hiện lệnh gọi get để truy xuất tất cả shippingsettings và postalCodeGroups.
Sao chép shippingsettings từ lệnh gọi get sang lệnh gọi update.
Nếu bạn không sử dụng nhãn thời gian vận chuyển trong dịch vụ vận chuyển, hãy xoá mục sau đây khỏi nội dung yêu cầu.
"transitTimeLabels": [ "all other labels" ],
Điền các khu vực mà bạn muốn sử dụng vào phần postalCodeGroups cho lệnh gọi update.
Thực hiện lệnh gọi update bằng các tài nguyên shippingsettings và postalCodeGroups.
Thêm dịch vụ giao hàng trong ngày
Bạn có thể sử dụng Merchant API để thiết lập dịch vụ vận chuyển giao hàng trong ngày nếu có kho hàng tại địa phương. Xem phần Thêm thông tin tại cửa hàng vào sản phẩm tại địa phương (addlocalinventory).
Dịch vụ vận chuyển giao hàng trong ngày có local_delivery làm shipmentType.
Bạn cần lưu ý những điều sau:
- Tất cả dịch vụ vận chuyển local_delivery đều được coi là dịch vụ giao hàng trong ngày.
- Bạn không thể thay đổi thông tin deliveryTime cho dịch vụ giao hàng tại địa phương.
Để thiết lập dịch vụ giao hàng trong ngày cho các sản phẩm trong kho hàng tại địa phương, hãy sử dụng phương thức accounts.shippingSettings.insert
.
Sau đây là một yêu cầu mẫu đặt loại lô hàng, storeConfig
(danh sách các cửa hàng mà sản phẩm của bạn được giao) và nhóm mức phí.
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings:insert
{
"etag": "",
"name": "accounts/ACCOUNT_ID/shippingSetting",
"services": [
{
"deliveryCountries": [
"COUNTRY_CODE"
],
"serviceName": "SERVICE_NAME",
"active": false,
"currencyCode": "CURRENCY_CODE",
"shipmentType": "SHIPMENT_TYPE",
"storeConfig": {
"cutoffConfig": {
"localCutoffTime": {
"hour": 7,
"minute": 40
}
},
"serviceRadius": {
"unit": "KILOMETERS",
"value": 40
},
"storeCodes": [],
"storeServiceType": "ALL_STORES"
},
"rateGroups": [
{
"applicableShippingLabels": [
"SHIPPING_LABEL"
],
"singleValue": {
"flatRate": {
"amountMicros": PRICE,
"currencyCode": "CURRENCY_CODE"
}
}
}
]
}
]
}
Thay thế nội dung sau:
- SHIPMENT_TYPE: Loại vị trí mà dịch vụ này vận chuyển đơn đặt hàng, bao gồm:
SHIPMENT_TYPE_UNSPECIFIED
DELIVERY
LOCAL_DELIVERY
COLLECTION_POINT
- SHIPPING_LABEL: Danh sách nhãn vận chuyển xác định những sản phẩm mà nhóm mức phí này áp dụng.
Sau đây là một phản hồi mẫu từ một lệnh gọi thành công:
{
"name": "accounts/ACCOUNT_ID/shippingSettings",
"services": [
{
"serviceName": "SERVICE_NAME",
"active": false,
"deliveryCountries": [
"COUNTRY_CODE"
],
"currencyCode": "CURRENCY_CODE",
"rateGroups": [
{
"applicableShippingLabels": [
"SHIPPING_LABEL"
],
"singleValue": {
"flatRate": {
"amountMicros": "PRICE",
"currencyCode": "CURRENCY_CODE"
}
}
}
],
"shipmentType": "SHIPMENT_TYPE",
"storeConfig": {
"storeServiceType": "ALL_STORES",
"cutoffConfig": {
"localCutoffTime": {
"hour": "7",
"minute": "40"
},
"noDeliveryPostCutoff": false
},
"serviceRadius": {
"value": "40",
"unit": "KILOMETERS"
}
}
}
],
"etag": "OAJCTQgBEAAaRwoEdGVzdBIEIgJVUxoDVVNEIggiBggHECgoACoeCAESDwoNCAESCU9WRVJTSVpFRBoJIgcIAhCAwtcvWAWSAQCaAQQIAhAo"
}
Thêm dịch vụ giao hàng vào ngày tiếp theo
Theo mặc định, các đơn đặt hàng được đặt sau hạn chót giao hàng trong ngày sẽ được lên lịch giao hàng vào ngày tiếp theo.
Để tắt dịch vụ giao hàng vào ngày tiếp theo, hãy đặt no_delivery_post_cutoff thành true.
Nếu bạn tắt dịch vụ giao hàng vào ngày tiếp theo, thì dịch vụ vận chuyển của bạn sẽ chỉ xuất hiện trước hạn chót mỗi ngày.
Bạn chỉ có thể sử dụng dịch vụ giao hàng vào ngày tiếp theo khi shipmentType là local_delivery.
Thêm chính sách trả lại hàng
Nếu đăng sản phẩm thông qua quảng cáo Mua sắm hoặc trang thông tin tự nhiên, bạn có thể sử dụng returnpolicyonline để tạo, xem, chỉnh sửa hoặc xoá chính sách trả lại hàng trực tuyến bằng các thuộc tính sau:
- Quốc gia mục tiêu, hãy xem bài viết Thiết lập chính sách trả lại hàng cho quảng cáo Mua sắm và trang thông tin miễn phí.
- Phí bổ sung hàng
- Phương thức trả lại hàng
- Tình trạng của mặt hàng trả lại
- Danh mục lý do trả lại hàng
- URL của chính sách trả lại hàng, hãy xem phần Thiết lập chính sách trả lại hàng cho quảng cáo Mua sắm và trang thông tin miễn phí.
Các sản phẩm được bán thông qua quảng cáo Mua sắm hoặc trang thông tin tự nhiên không yêu cầu địa chỉ trả lại hàng.
Để biết thêm thông tin chi tiết, hãy xem bài viết Thiết lập chính sách trả lại hàng cho quảng cáo Mua sắm và trang thông tin tự nhiên.
Bạn có thể sử dụng returnpolicyonline.create để thêm chính sách trả lại hàng. Phản hồi này bao gồm chính sách mới cập nhật.
POST https://merchantapi.googleapis.com/v1/{ACCOUNT_ID}/returnpolicyonline