Sử dụng API phụ về 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 của bạ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 API Sản phẩm Merchant.
Để biết thêm thông tin, hãy xem 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ả tài khoản phụ được liên kết.
Các tài khoản nâng cao thường được dùng bởi các đơn vị tích hợp, đơn vị tổng hợp và đối tác kênh quản lý các cửa hàng trực tuyến và dịch vụ API cho nhiều doanh nghiệp. Các 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.
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
accounts.shippingSettings.insert
phương thức.
Yêu cầu mẫu sau đây sẽ đặt giá vận chuyển, các chương trình khách hàng thân thiết mà dịch vụ vận chuyển này được 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 {ACCESS_TOKEN}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"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"}}}]}]}' \
--compressed
Thay thế nội dung sau:
- {ACCOUNT_ID}: Mã nhận dạng duy nhất của tài khoản Merchant Center của bạn.
- {COUNTRY_CODE}: Mã CLDR (Kho lưu trữ dữ liệu vị trí chung) của quốc gia mà dịch vụ này áp dụng. Phải khớp với mã của giá trong các nhóm mức giá.
- {SERVICE_NAME}: Tên của dịch vụ.
- {PROGRAM_LABEL}: Nhãn chương trình khách hàng thân thiết được đặt trong phần cài đặt chương trình khách hàng thân thiết trong Merchant Center.
- {SHIPPING_LABEL}: Danh sách nhãn vận chuyển xác định các sản phẩm mà nhóm mức giá này áp dụng.
- {PRICE}: Giá được biểu thị dưới dạng một số tính bằng micro. Ví dụ: 1 USD = 1.000.000 micro.
- {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, 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 huỷ bỏ các giá trị hiện có.
Dưới đây là 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"
}
Dưới đây là mẫu mà 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 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.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 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 {ACCESS_TOKEN}' \
--header 'Accept: application/json' \
--compressed
Dưới đây là 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.
Dưới đây là cách sử dụng Merchant API để quản lý kho hàng:
Để truy xuất tất cả
shippingsettingsvàwarehouseshiện có, hãy đưa ra yêu cầuGETbằng phương thứcaccounts.shippingSettings.getShippingSettings.Tạo yêu cầu bằng phương thức
account.shippingSettings.insert. Sao chép tài nguyênshippingsettingstừ phản hồi của yêu cầuGETvào 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
warehousestrong 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 sẽ đặ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}: Mã nhận dạng duy nhất của tài khoản Merchant Center của bạn.
- {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ã. Trường này cũng có thể bao gồm các địa phương phụ thuộc hoặc địa phương 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".
Dưới đây là 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"
}
Đặt nhóm mã bưu chính
Sử dụng API phụ về Tài khoản để quản lý các khu vực, được gọi là postalCodeGroups, cho tài khoản Merchant Center.
Tài nguyên postalCodeGroups là danh sách các nhóm, trong đó mỗi nhóm là 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 vào 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 các 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 bài viết Thêm thông tin về cửa hàng vào sản phẩm tại địa phương (addlocalinventory).
Các dịch vụ vận chuyển giao hàng trong ngày có local_delivery làm shipmentType.
Áp dụng các lưu ý sau:
- Tất cả cá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 các 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.
Dưới đây là 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 từ đó) và các nhóm mức giá.
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 địa điểm mà dịch vụ này vận chuyển
đơn đặt hàng đến, bao gồm:
SHIPMENT_TYPE_UNSPECIFIEDDELIVERYLOCAL_DELIVERYCOLLECTION_POINT
- {SHIPPING_LABEL}: Danh sách nhãn vận chuyển xác định các sản phẩm mà nhóm mức giá này áp dụng.
Dưới đây là 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 thời gian hạn chót nhận đơn hàng của dịch vụ 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ì các dịch vụ vận chuyển của bạn sẽ chỉ hiển thị trước thời gian hạn chót nhận đơn hàng 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 bạn liệt kê 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á các chính sách trả lại hàng trực tuyến bằng các thuộc tính sau:
- Các 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í nhập kho lại
- Phương thức trả lại hàng
- Tình trạng mặt hàng trả lại
- Danh mục lý do trả lại hàng
- URL chính sách trả lại hàng, 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í.
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 đã cập nhật.
POST https://merchantapi.googleapis.com/v1/{ACCOUNT_ID}/returnpolicyonline