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

แหล่งข้อมูล 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 เพื่อจัดการข้อมูลคลังสินค้าสำหรับบัญชี 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 ที่มีคลังสินค้าสำหรับคลังสินค้า 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 โปรดดูหัวข้อ การย้ายข้อมูลการจัดการการตั้งค่าการจัดส่ง