แหล่งข้อมูล
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 เป็น true หากปิดการนำส่งในวันถัดไป
บริการจัดส่งจะแสดงเฉพาะก่อนเวลาปิดรับคำสั่งซื้อในแต่ละวัน
การนำส่งในวันถัดไปจะพร้อมใช้งานเมื่อ shipment_type เป็น
local_delivery เท่านั้น
ดูข้อมูลเพิ่มเติม
ดูข้อมูลเกี่ยวกับการย้ายข้อมูลจาก Content API for Shopping ได้ที่ย้ายข้อมูลการจัดการการตั้งค่าการจัดส่ง