ภาพรวมการตั้งค่าการจัดส่ง

ทรัพยากร ShippingSettings ช่วยให้คุณเรียกข้อมูลและอัปเดตการตั้งค่าการจัดส่งของบัญชีได้

Google สามารถอัปเดตเวลานำส่งโดยประมาณสำหรับผลิตภัณฑ์บางรายการได้โดยอัตโนมัติ ดูข้อมูลเพิ่มเติมได้ที่เปิดใช้การปรับปรุงอัตโนมัติ

อ่าน เขียน หรืออัปเดตการตั้งค่าการจัดส่ง

หากต้องการใช้บริการจัดส่งของ Merchant API ให้ทำดังนี้

  1. ส่งคำขอ GET เพื่อดึงข้อมูลการตั้งค่าการจัดส่งทั้งหมดของบัญชี
  2. แก้ไขการตั้งค่าการจัดส่ง
  3. ส่งคำขอ 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 เพื่อจัดการคลังสินค้ามีดังนี้

  1. ส่งคำขอ GET เพื่อดึงข้อมูล shippingsettings และคลังสินค้าที่มีอยู่ทั้งหมด
  2. คัดลอก shippingsettings จากคำขอ GET ไปยังคำขอ UPDATE

  3. ป้อนข้อมูลคลังสินค้าหากต้องการใช้ในส่วน warehouses สำหรับคำขอ INSERT

  4. ส่งคำขอ UPDATE ที่มีทรัพยากร shippingsettings และ warehouses

ต่อไปนี้คือตัวอย่างเนื้อหาคำขอ INSERT ที่มีคลังสินค้าสำหรับ Warehouse 1 ซึ่งอัปเดตจาก New York เป็น Mountain View

{
  "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 ได้ที่ย้ายข้อมูลการจัดการการตั้งค่าการจัดส่ง