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

يتيح لك المورد 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 يتضمّن المستودع Warehouse 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، يُرجى الاطّلاع على نقل إدارة إعدادات الشحن.