ใช้ Accounts sub-API เพื่อจัดการการตั้งค่าการจัดส่งสำหรับผลิตภัณฑ์ทั้งหมดในบัญชีและบัญชีย่อยทั้งหมดที่เชื่อมโยง
การเปลี่ยนแปลงที่คุณทำกับการตั้งค่าการจัดส่งจะมีผลกับผลิตภัณฑ์ทั้งหมด หากต้องการอัปเดตการจัดส่งสำหรับผลิตภัณฑ์แต่ละรายการ ให้ใช้ Merchant Products API
ดูข้อมูลเพิ่มเติมได้ที่ ตั้งค่าการจัดส่ง
ภาพรวมของการตั้งค่าการจัดส่ง
ทรัพยากร
accounts.shippingSettings
ช่วยให้คุณดึงและอัปเดตการตั้งค่าการจัดส่งของบัญชีขั้นสูง
และบัญชีย่อยทั้งหมดที่เชื่อมโยงได้
โดยปกติแล้ว บัญชีขั้นสูงจะใช้โดยผู้ผสานระบบ ผู้รวบรวมข้อมูล และพาร์ทเนอร์ช่องทางที่จัดการร้านค้าออนไลน์และบริการ API สำหรับธุรกิจหลายแห่ง นอกจากนี้ ธุรกิจที่มีร้านค้าออนไลน์หรือแบรนด์หลายรายการที่จำหน่ายในเว็บไซต์แยกกันยังเลือกที่จะมีบัญชีย่อยภายใต้บัญชีขั้นสูงบัญชีเดียวได้ด้วย
Google สามารถอัปเดตเวลานำส่งโดยประมาณสำหรับผลิตภัณฑ์บางรายการได้โดยอัตโนมัติ
เพิ่มการตั้งค่าการจัดส่ง
หากต้องการเพิ่มหรืออัปเดตการตั้งค่าการจัดส่งสำหรับบัญชี ให้ใช้
accounts.shippingSettings.insert
วิธี
คำขอตัวอย่างต่อไปนี้จะกำหนดราคาการจัดส่ง โปรแกรมสะสมคะแนนที่บริการจัดส่งนี้ใช้ได้ และรหัสสกุลเงิน
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
แทนที่ค่าต่อไปนี้
- {ACCOUNT_ID}: ตัวระบุที่ไม่ซ้ำกันของบัญชี Merchant Center
- {COUNTRY_CODE}: รหัส CLDR (Common Locale Data Repository) ของประเทศที่บริการนี้มีผล ต้องตรงกับรหัสของราคาในกลุ่มอัตราค่าจัดส่ง
- {SERVICE_NAME}: ชื่อบริการ
- {PROGRAM_LABEL}: ป้ายกำกับโปรแกรมสะสมคะแนนที่กำหนดไว้ในการตั้งค่าโปรแกรมสะสมคะแนนใน Merchant Center
- {SHIPPING_LABEL}: รายการป้ายกำกับการจัดส่งที่กำหนด ผลิตภัณฑ์ที่กลุ่มอัตราค่าจัดส่งนี้มีผล
- {PRICE}: ราคาที่แสดงเป็นตัวเลขในหน่วยไมโคร เช่น 1 ดอลลาร์สหรัฐ = 1,000,000 ไมโคร
- {CURRENCY_CODE}: สกุลเงินของราคาโดยใช้ ตัวย่อ 3 ตัวอักษร
ดูข้อมูลเพิ่มเติมเกี่ยวกับช่องที่ระบุได้ใน เอกสารอ้างอิง
เนื้อหาคำขอควรมีเนื้อหาทรัพยากรแบบเต็มของทรัพยากร accounts.shippingSettings แม้ว่าคุณจะอัปเดตแอตทริบิวต์เดียวก็ตาม เนื่องจากค่า NULL หรือค่าที่ขาดหายไปในเนื้อหาคำขอจะทำให้ค่าที่มีอยู่เป็นค่าว่าง
นี่คือตัวอย่างการตอบกลับจากการเรียกที่สำเร็จ
{
"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"
}
นี่คือตัวอย่างที่คุณใช้เพื่ออัปเดตการตั้งค่าการจัดส่งสำหรับบัญชีที่กำหนด โดยใช้ ไลบรารีของไคลเอ็นต์:
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()
ดึงข้อมูลการตั้งค่าการจัดส่ง
คำขอต่อไปนี้แสดงวิธีดึงข้อมูลการตั้งค่าการจัดส่งของบัญชี 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
นี่คือตัวอย่างที่คุณใช้เพื่อดึงข้อมูลการตั้งค่าการจัดส่ง สำหรับบัญชีที่กำหนดโดยใช้ ไลบรารีของไคลเอ็นต์ได้
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()
เพิ่มการตั้งค่าคลังสินค้า
หากต้องการเพิ่มหรืออัปเดตการตั้งค่าคลังสินค้าที่จัดเก็บและจัดการสินค้าคงคลังสำหรับ
บัญชี ให้ใช้วิธี
accounts.shippingSettings.insert
วิธีใช้ Merchant API เพื่อจัดการคลังสินค้ามีดังนี้
หากต้องการดึงข้อมูล
shippingsettingsและwarehousesที่มีอยู่ทั้งหมด ให้ส่งคำขอGETโดยใช้วิธีaccounts.shippingSettings.getShippingSettingsสร้างคำขอโดยใช้วิธี
account.shippingSettings.insertคัดลอกทรัพยากรshippingsettingsจากการตอบกลับของคำขอGETไปยังคำขอแทรกหากต้องการเพิ่มข้อมูลเกี่ยวกับคลังสินค้าโดยใช้การเรียกแทรก ให้ป้อนรายละเอียดเกี่ยวกับคลังสินค้าในทรัพยากร
warehousesในเนื้อหาคำขอเรียกใช้คำขอแทรก
คำขอตัวอย่างต่อไปนี้แสดงวิธีใช้วิธี accounts.shippingSettings.insert เพื่ออัปเดตการตั้งค่าคลังสินค้าสำหรับบัญชี คำขอจะกำหนดเวลาของวันที่จะยอมรับคำสั่งซื้อและเริ่มดำเนินการ วันที่ดำเนินการ และที่อยู่สำหรับจัดส่ง
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}"
}
}
]
}
แทนที่ค่าต่อไปนี้
- {ACCOUNT_ID}: ตัวระบุที่ไม่ซ้ำกันของบัญชี Merchant Center
- {WAREHOUSE_NAME}: ชื่อคลังสินค้า
- {ADDRESS}: ที่อยู่สำหรับจัดส่งของคลังสินค้า
- {CITY_NAME}: เมือง เขตเมือง หรือตำบล นอกจากนี้ยังรวมถึงท้องถิ่นที่ขึ้นอยู่กับท้องถิ่นอื่นหรือท้องถิ่นย่อย เช่น ย่านหรือชานเมือง
- {POSTAL_CODE}: รหัสไปรษณีย์ เช่น 94043
- {REGION_CODE}: รหัสประเทศ CLDR code เช่น "US"
นี่คือตัวอย่างการตอบกลับจากการเรียกที่สำเร็จ
{
"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"
}
ตั้งค่ากลุ่มรหัสไปรษณีย์
ใช้ Accounts sub-API เพื่อจัดการภูมิภาคที่เรียกว่า postalCodeGroups สำหรับ บัญชี Merchant Center
ทรัพยากร postalCodeGroups คือรายการการจัดกลุ่ม โดยการจัดกลุ่มแต่ละรายการคือรายการรหัสไปรษณีย์หลายรายการที่มีการตั้งค่าการจัดส่งเหมือนกัน
ใช้ Merchant API เพื่อจัดการ postalCodeGroups ดังนี้
ส่งคำขอ get เพื่อดึงข้อมูล shippingsettings และ postalCodeGroups ทั้งหมด
คัดลอก shippingsettings จากคำขอ get ไปยังคำขอ update
หากไม่ได้ใช้ป้ายกำกับเวลาขนส่งในบริการจัดส่ง ให้นำรายการต่อไปนี้ออกจากเนื้อหาคำขอ
"transitTimeLabels": [ "all other labels" ],ป้อนภูมิภาคที่ต้องการใช้ในส่วน postalCodeGroups สำหรับคำขอ update
ส่งคำขอ update พร้อมทรัพยากร shippingsettings และ postalCodeGroups
เพิ่มการนำส่งวันเดียวกัน
คุณใช้ Merchant API เพื่อกำหนดค่าบริการจัดส่งแบบนำส่งวันเดียวกันได้หากมีสินค้าคงคลังในร้าน ดูเพิ่มข้อมูลในร้านลงในผลิตภัณฑ์ในร้าน (addlocalinventory)
บริการจัดส่งแบบนำส่งวันเดียวกันจะมี local_delivery เป็น shipmentType
ข้อควรระวังต่อไปนี้มีผลบังคับใช้
- ระบบจะพิจารณาว่าบริการจัดส่ง local_delivery ทั้งหมดเป็นการนำส่งวันเดียวกัน
- คุณไม่สามารถเปลี่ยนข้อมูล deliveryTime สำหรับการนำส่งในพื้นที่ได้
หากต้องการตั้งค่าการนำส่งวันเดียวกันสำหรับผลิตภัณฑ์สินค้าคงคลังในร้าน ให้ใช้วิธี accounts.shippingSettings.insert
นี่คือคำขอตัวอย่างที่กำหนดประเภทการจัดส่ง storeConfig (รายการร้านค้าที่จัดส่งผลิตภัณฑ์) และกลุ่มอัตราค่าจัดส่ง
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}"
}
}
}
]
}
]
}
แทนที่ค่าต่อไปนี้
- {SHIPMENT_TYPE}: ประเภทสถานที่ที่บริการนี้จัดส่ง
คำสั่งซื้อ ซึ่งรวมถึง:
SHIPMENT_TYPE_UNSPECIFIEDDELIVERYLOCAL_DELIVERYCOLLECTION_POINT
- {SHIPPING_LABEL}: รายการป้ายกำกับการจัดส่งที่กำหนด ผลิตภัณฑ์ที่กลุ่มอัตราค่าจัดส่งนี้มีผล
นี่คือตัวอย่างการตอบกลับจากการเรียกที่สำเร็จ
{
"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"
}
เพิ่มการนำส่งในวันถัดไป
ระบบจะกำหนดเวลาให้คำสั่งซื้อที่ส่งหลังเวลาตัดรอบคำสั่งซื้อสำหรับการนำส่งวันเดียวกันเป็นการนำส่งในวันถัดไปโดยค่าเริ่มต้น
หากต้องการปิดการนำส่งในวันถัดไป ให้ตั้งค่า no_delivery_post_cutoff เป็น true
หากปิดการนำส่งในวันถัดไป บริการจัดส่งจะแสดงเฉพาะก่อนเวลาตัดรอบคำสั่งซื้อในแต่ละวัน
การนำส่งในวันถัดไปจะใช้ได้เฉพาะเมื่อ shipmentType เป็น local_delivery
เพิ่มนโยบายคืนสินค้า
หากแสดงผลิตภัณฑ์ผ่านโฆษณา Shopping หรือข้อมูลที่แสดงฟรี คุณสามารถใช้ returnpolicyonline เพื่อสร้าง ดู แก้ไข หรือลบนโยบายคืนสินค้าออนไลน์ด้วยแอตทริบิวต์ต่อไปนี้
- ประเทศเป้าหมาย โปรดดู ตั้งค่านโยบายคืนสินค้าสำหรับโฆษณา Shopping และข้อมูลที่แสดงฟรี
- ค่าธรรมเนียมการเติมสินค้า
- วิธีการคืนสินค้า
- สภาพสินค้าที่ส่งคืน
- หมวดหมู่เหตุผลในการคืนสินค้า
- URL นโยบายคืนสินค้า โปรดดู ตั้งค่านโยบายคืนสินค้าสำหรับโฆษณา Shopping และข้อมูลที่แสดงฟรี
ผลิตภัณฑ์ที่จำหน่ายผ่านโฆษณา Shopping หรือข้อมูลที่แสดงฟรีไม่จำเป็นต้องมีที่อยู่สำหรับคืนสินค้า
ดูรายละเอียดเพิ่มเติมได้ที่ ตั้งค่านโยบายคืนสินค้าสำหรับโฆษณา Shopping และข้อมูลที่แสดงฟรี
คุณสามารถใช้ returnpolicyonline.create เพื่อเพิ่มนโยบายคืนสินค้า การตอบกลับจะมีนโยบายที่อัปเดต
POST https://merchantapi.googleapis.com/v1/{ACCOUNT_ID}/returnpolicyonline