نظرة عامة على إعدادات الشحن

The ShippingSettings يتيح لك مرجع استرداد إعدادات الشحن في حسابك وتعديلها.

يمكن أن تعدّل Google تلقائيًا المدة المُقدَّرة للتسليم لبعض المنتجات. لمزيد من المعلومات، يُرجى الاطّلاع على مقالة تفعيل التحسينات التلقائية.

قراءة إعدادات الشحن أو كتابتها أو تعديلها

لاستخدام خدمة الشحن في Merchant API، يُرجى اتّباع الخطوات التالية:

  1. أرسِل طلب GET لاسترداد إعدادات الشحن الكاملة لحسابك.
  2. عدِّل إعدادات الشحن.
  3. أرسِل طلب INSERT يتضمّن إعدادات الشحن المعدَّلة.

Etag

Etag هو رمز مميّز مشفّر لتجنُّب التعديلات غير المتزامنة. يتغيّر etag عند تغيير أيّ من بيانات إعدادات الشحن. على المستخدمين نسخ etag الذي حصلوا عليه من طلب GET إلى نص طلب INSERT.

إذا تغيّرت بيانات إعدادات الشحن بين طلب GET وطلب INSERT، ستظهر لك رسالة خطأ تطلب إرسال طلب GET آخر لاسترداد أحدث رمز etag. عليك إرسال طلب GET لاسترداد رمز 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 على "صحيح" (true). إذا أوقفت خدمة التسليم في اليوم التالي، لن تظهر خدمات الشحن إلا قبل الموعد النهائي كل يوم.

لا تتوفّر خدمة التسليم في اليوم التالي إلا عندما يكون shipment_type هو local_delivery.

مزيد من المعلومات

للتعرّف على كيفية الانتقال من Content API for Shopping، يُرجى الاطّلاع على مقالة نقل إدارة إعدادات الشحن.