แหล่งข้อมูล ShippingSettings
จะช่วยให้คุณเรียกข้อมูลและอัปเดตการตั้งค่าการจัดส่งของบัญชีได้
Google สามารถอัปเดตเวลานำส่งโดยประมาณสำหรับผลิตภัณฑ์บางรายการโดยอัตโนมัติ โปรดดูข้อมูลเพิ่มเติมที่หัวข้อเปิดใช้การปรับปรุงอัตโนมัติ
อ่าน เขียน หรืออัปเดตการตั้งค่าการจัดส่ง
หากต้องการใช้บริการจัดส่งของ Merchant API ให้ทำดังนี้
- ส่งคำขอ
GET
เพื่อเรียกข้อมูลการตั้งค่าการจัดส่งทั้งหมดของบัญชี - แก้ไขการตั้งค่าการจัดส่ง
- ส่งคำขอ
INSERT
ที่มีการตั้งค่าการจัดส่งที่แก้ไขแล้ว
Etag
Etag คือโทเค็นที่เข้ารหัสเพื่อหลีกเลี่ยงการอัปเดตแบบไม่พร้อมกัน ข้อมูล ETag จะเปลี่ยนแปลงเมื่อข้อมูลการตั้งค่าการจัดส่งมีการเปลี่ยนแปลง ผู้ใช้ต้องคัดลอก etag ที่ได้รับจากคำขอ GET
ไปยังเนื้อหาคำขอ 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"
}
]
}
]
}
ต่อไปนี้คือตัวอย่างที่คุณสามารถใช้เพื่อแทรกการตั้งค่าการจัดส่ง
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}: ส่วนที่อยู่บนถนนของที่อยู่ของคลังสินค้า
- {city}: เมือง เมืองเล็ก หรือเทศบาลที่โกดังตั้งอยู่
- {administrative_area}: เขตการปกครองย่อยของประเทศ เช่น รัฐ
- {postal_code}: รหัสไปรษณีย์
- {region_code}: รหัสประเทศในรูปแบบสตริง
- {minutes}: นาทีที่เป็นส่วนหนึ่งของเวลาปิดรับคำสั่งซื้อจนถึงเวลาที่ต้องทำคำสั่งซื้อเพื่อให้คลังสินค้าประมวลผลในวันเดียวกัน
- {handling_days}: จำนวนวันที่คลังสินค้านี้ใช้ในการแพ็คและจัดส่งสินค้า
ทรัพยากร warehouses
คือรายการคลังสินค้า คุณสามารถอ้างอิงเวลานำส่งตามคลังสินค้าของบริการจัดส่งแต่ละรายการผ่าน warehouse.name
จัดการคลังสินค้า
วิธีใช้ Merchant API เพื่อจัดการคลังสินค้ามีดังนี้
- ส่งคำขอ
GET
เพื่อเรียกข้อมูลshippingsettings
และโกดังที่มีอยู่ทั้งหมด คัดลอก
shippingsettings
จากคำขอGET
ไปยังคำขอUPDATE
ป้อนข้อมูลคลังสินค้าหากต้องการใช้ในส่วนที่
warehouses
สำหรับคำขอINSERT
ส่งคําขอ
UPDATE
ที่มีทรัพยากรshippingsettings
และwarehouses
ต่อไปนี้คือตัวอย่างINSERT
เนื้อหาคำขอที่มีคลังสินค้าสำหรับคลังสินค้า 1 ที่อัปเดตจากนิวยอร์กเป็นเมาน์เทนวิว
{
"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 เพื่อกำหนดค่าบริการนำส่งวันเดียวกันได้หากมีสินค้าคงคลังในร้าน บริการนำส่งวันเดียวกันจะมี local_delivery
เป็น shipment_type
ขณะนี้บริการจัดส่ง 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
เป็น "จริง" หากคุณปิดการนำส่งวันถัดไป บริการจัดส่งจะแสดงก่อนเวลาปิดรับคำสั่งซื้อในแต่ละวันเท่านั้น
การนำส่งในวันถัดไปจะใช้ได้ก็ต่อเมื่อ shipment_type
มีค่าเป็น
local_delivery
ดูข้อมูลเพิ่มเติม
ดูข้อมูลเกี่ยวกับการย้ายข้อมูลจาก Content API for Shopping ได้ที่ย้ายข้อมูลการจัดการการตั้งค่าการจัดส่ง