管理運送設定

使用 Accounts 子 API 管理帳戶和所有相關聯子帳戶中所有產品的運送設定。

你對運送設定所做的變更會套用至所有產品。如要更新個別產品的運送資訊,請使用 Merchant Products API。

詳情請參閱「設定運送設定」。

運送設定總覽

你可以透過 accounts.shippingSettings 資源,擷取及更新進階帳戶和所有相關聯子帳戶的運送設定。

進階帳戶通常適用於整合商、匯總商和通路合作夥伴,他們為多個商家管理網路商店和 API 服務。如果商家有多個網路商店或品牌,且在不同網站上銷售,也可以選擇在單一進階帳戶下建立子帳戶。

Google 會自動更新部分產品的預估送達時間。

新增運送設定

如要新增或更新帳戶的運送設定,請使用 accounts.shippingSettings.insert 方法。

下列要求範例會設定運費、這項運送服務適用的會員方案,以及幣別代碼。

HTTP

POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings:insert

{
  "etag": "",
  "name": "accounts/ACCOUNT_ID/shippingSetting",
  "services": [
    {
      "deliveryCountries": [
        "COUNTRY_CODE"
      ],
      "serviceName": "SERVICE_NAME",
      "active": false,
      "deliveryTime": {},
      "loyaltyPrograms": [
        {
          "programLabel": "PROGRAM_LABEL"
        }
      ],
      "minimumOrderValue": {
        "amountMicros": PRICE,
        "currencyCode": "CURRENCY_CODE"
      },
      "currencyCode": "USD",
      "rateGroups": [
        {
          "applicableShippingLabels": [
            "SHIPPING_LABEL"
          ],
          "singleValue": {
            "flatRate": {
              "amountMicros": 10000000,
              "currencyCode": "USD"
            }
          }
        }
      ]
    }
  ]
}

cURL

curl --request POST \
'https://merchantapi.googleapis.com/accounts/v1/accounts/ACCOUNT_ID/shippingSettings:insert' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"name":"SHIPPING_SETTING_NAME","services":[{"serviceName":"SERVICE_NAME","currencyCode":"CURRENCY_CODE","rateGroups":[{"applicableShippingLabels":["SHIPPING_LABEL"],"carrierRates":[{"name":"new","carrier":"CARRIER_NAME","carrierService":"CARRIER_SERVICE","originPostalCode":"ZIPCODE"}],"singleValue":{"flatRate":{"amountMicros":10000000,"currencyCode":"USD"}}}],"deliveryCountries":["COUNTRY_CODE"],"deliveryTime":{"maxHandlingDays":2,"minHandlingDays":1},"minimumOrderValue":{"amountMicros":50000000,"currencyCode":"USD"},"active":false}]}' \
--compressed

更改下列內容:

  • ACCOUNT_ID:Merchant Center 帳戶的專屬 ID。
  • COUNTRY_CODE:這項服務適用國家/地區的 CLDR (通用區域資料庫) 代碼。必須與費率群組中的價格相符。
  • SERVICE_NAME:服務名稱。
  • CARRIER_NAME:貨運公司名稱。例如 UPS 和 Fedex。
  • CARRIER_SERVICE:貨運公司支援的服務。 如需完整的貨運公司服務清單,請參閱貨運公司費率 (僅適用於澳洲、德國、英國和美國)
    • PROGRAM_LABEL:你在 Merchant Center 會員方案設定中設定的會員方案標籤。
  • SHIPPING_LABEL:運送標籤清單,定義適用這個費率群組的產品。
  • PRICE:以微元表示的價格,例如 1 美元 = 1000000 個百萬分之一。
  • CURRENCY_CODE:價格的幣別,使用三個字母的縮寫。

如要進一步瞭解指定欄位,請參閱參考說明文件

要求主體應包含 accounts.shippingSettings 資源的完整資源主體,即使您只更新單一屬性也是如此,因為要求主體中的任何 NULL 或遺漏值都會導致現有值為空值。

以下是成功呼叫的回應範例:

{
  "name": "accounts/ACCOUNT_ID/shippingSettings",
  "services": [
    {
      "serviceName": "SERVICE_NAME",
      "active": false,
      "deliveryCountries": [
        "COUNTRY_CODE"
      ],
      "currencyCode": "CURRENCY_CODE",
      "rateGroups": [
        {
          "applicableShippingLabels": [
            "SHIPPING_LABEL"
          ],
          "singleValue": {
            "flatRate": {
              "amountMicros": "PRICE",
              "currencyCode": "CURRENCY_CODE"
            }
          }
        }
      ],
      "shipmentType": "LOCAL_DELIVERY",
      "storeConfig": {
        "storeServiceType": "ALL_STORES",
        "cutoffConfig": {
          "localCutoffTime": {
            "hour": "7",
            "minute": "40"
          },
          "noDeliveryPostCutoff": false
        },
        "serviceRadius": {
          "value": "40",
          "unit": "KILOMETERS"
        }
      }
    }
  ],
  "etag": "OAJCTQgBEAAaRwoEdGVzdBIEIgJVUxoDVVNEIggiBggHECgoACoeCAESDwoNCAESCU9WRVJTSVpFRBoJIgcIAhCAwtcvWAWSAQCaAQQIAhAo"
}

以下範例說明如何使用用戶端程式庫,更新特定帳戶的運送設定:

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.DeliveryTime;
import com.google.shopping.merchant.accounts.v1.InsertShippingSettingsRequest;
import com.google.shopping.merchant.accounts.v1.RateGroup;
import com.google.shopping.merchant.accounts.v1.Service;
import com.google.shopping.merchant.accounts.v1.Service.ShipmentType;
import com.google.shopping.merchant.accounts.v1.ShippingSettings;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.Value;
import com.google.shopping.type.Price;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to insert a ShippingSettings for a Merchant Center account. */
public class InsertShippingSettingsSample {

  private static String getParent(String accountId) {
    return String.format("accounts/%s", accountId);
  }

  public static void insertShippingSettings(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    ShippingSettingsServiceSettings shippingSettingsServiceSettings =
        ShippingSettingsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates parent to identify where to insert the shippingsettings.
    String parent = getParent(config.getAccountId().toString());

    // Calls the API and catches and prints any network failures/errors.
    try (ShippingSettingsServiceClient shippingSettingsServiceClient =
        ShippingSettingsServiceClient.create(shippingSettingsServiceSettings)) {

      InsertShippingSettingsRequest request =
          InsertShippingSettingsRequest.newBuilder()
              .setParent(parent)
              .setShippingSetting(
                  ShippingSettings.newBuilder()
                      // Etag needs to be an empty string on initial insert
                      // On future inserts, call GET first to get the Etag
                      // Then use the retrieved Etag on future inserts.
                      // NOTE THAT ON THE INITIAL INSERT, YOUR SHIPPING SETTINGS WILL
                      // NOT BE STORED, YOU HAVE TO CALL INSERT AGAIN WITH YOUR
                      // RETRIEVED ETAG.
                      // .setEtag("")
                      .setEtag("PPa=")
                      .addServices(
                          Service.newBuilder()
                              .setServiceName("Canadian Postal Service")
                              .setActive(true)
                              .addDeliveryCountries("CA")
                              .setCurrencyCode("CAD")
                              .setDeliveryTime(
                                  DeliveryTime.newBuilder()
                                      .setMinTransitDays(0)
                                      .setMaxTransitDays(3)
                                      .setMinHandlingDays(0)
                                      .setMaxHandlingDays(3)
                                      .build())
                              .addRateGroups(
                                  RateGroup.newBuilder()
                                      .addApplicableShippingLabels("Oversized")
                                      .addApplicableShippingLabels("Perishable")
                                      .setSingleValue(Value.newBuilder().setPricePercentage("5.4"))
                                      .setName("Oversized and Perishable items")
                                      .build())
                              .setShipmentType(ShipmentType.DELIVERY)
                              .setMinimumOrderValue(
                                  Price.newBuilder()
                                      .setAmountMicros(10000000)
                                      .setCurrencyCode("CAD")
                                      .build())
                              .build())
                      .build())
              .build();

      System.out.println("Sending insert ShippingSettings request");
      ShippingSettings response = shippingSettingsServiceClient.insertShippingSettings(request);
      System.out.println("Inserted ShippingSettings Name below");
      System.out.println(response.getName());
      // You can apply ShippingSettings to specific products by using the `shippingLabel` field
      // on the product.
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    insertShippingSettings(config);
  }
}

PHP

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\ShippingSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\DeliveryTime;
use Google\Shopping\Merchant\Accounts\V1\InsertShippingSettingsRequest;
use Google\Shopping\Merchant\Accounts\V1\RateGroup;
use Google\Shopping\Merchant\Accounts\V1\Service;
use Google\Shopping\Merchant\Accounts\V1\Service\ShipmentType;
use Google\Shopping\Merchant\Accounts\V1\ShippingSettings;
use Google\Shopping\Merchant\Accounts\V1\Value;
use Google\Shopping\Type\Price;

/**
 * This class demonstrates how to insert a ShippingSettings for a Merchant Center account.
 */
class InsertShippingSettings
{
    /**
     * A helper function to create the parent string.
     *
     * @param string $accountId The account ID.
     * @return string The parent in the format "accounts/{accountId}".
     */
    private static function getParent(string $accountId): string
    {
        return sprintf("accounts/%s", $accountId);
    }

    /**
     * Inserts shipping settings for the specified Merchant Center account.
     *
     * @param array $config The configuration data containing the account ID.
     * @return void
     */
    public static function insertShippingSettings($config)
    {
        // Gets the OAuth credentials to make the request.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates options config containing credentials for the client to use.
        $options = ['credentials' => $credentials];

        // Creates a client.
        $shippingSettingsServiceClient = new ShippingSettingsServiceClient($options);

        // Creates parent to identify where to insert the shippingsettings.
        $parent = self::getParent($config['accountId']);

        // Calls the API and catches and prints any network failures/errors.
        try {
            $request = (new InsertShippingSettingsRequest())
                ->setParent($parent)
                ->setShippingSetting(
                    (new ShippingSettings())
                        // Etag needs to be an empty string on initial insert
                        // On future inserts, call GET first to get the Etag
                        // Then use the retrieved Etag on future inserts.
                        // NOTE THAT ON THE INITIAL INSERT, YOUR SHIPPING SETTINGS WILL
                        // NOT BE STORED, YOU HAVE TO CALL INSERT AGAIN WITH YOUR
                        // RETRIEVED ETAG.
                        ->setEtag("")
                        ->setServices([
                            (new Service())
                                ->setServiceName("Canadian Postal Service")
                                ->setActive(true)
                                ->setDeliveryCountries(["CA"])
                                ->setCurrencyCode("CAD")
                                ->setDeliveryTime(
                                    (new DeliveryTime())
                                        ->setMinTransitDays(0)
                                        ->setMaxTransitDays(3)
                                        ->setMinHandlingDays(0)
                                        ->setMaxHandlingDays(3)
                                )
                                ->setRateGroups(
                                    [(new RateGroup())
                                        ->setApplicableShippingLabels(["Oversized","Perishable"])
                                        ->setSingleValue((new Value())->setPricePercentage("5.4"))
                                        ->setName("Oversized and Perishable items")]
                                )
                                ->setShipmentType(ShipmentType::DELIVERY)
                                ->setMinimumOrderValue(
                                    (new Price())
                                        ->setAmountMicros(10000000)
                                        ->setCurrencyCode("CAD")
                                )
                        ])
                );

            print "Sending insert ShippingSettings request" . PHP_EOL;
            $response = $shippingSettingsServiceClient->insertShippingSettings($request);
            print "Inserted ShippingSettings below" . PHP_EOL;
            print_r($response);
            // You can apply ShippingSettings to specific products by using the `shippingLabel` field
            // on the product.
        } catch (ApiException $e) {
            print $e->getMessage();
        }
    }

    /**
     * Helper to execute the sample.
     *
     * @return void
     */
    public function callSample(): void
    {
        $config = Config::generateConfig();

        // Makes the call to insert shipping settings for the MC account.
        self::insertShippingSettings($config);
    }
}

// Run the script
$sample = new InsertShippingSettings();
$sample->callSample();

Python

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import DeliveryTime
from google.shopping.merchant_accounts_v1 import InsertShippingSettingsRequest
from google.shopping.merchant_accounts_v1 import RateGroup
from google.shopping.merchant_accounts_v1 import Service
from google.shopping.merchant_accounts_v1 import ShippingSettings
from google.shopping.merchant_accounts_v1 import ShippingSettingsServiceClient
from google.shopping.merchant_accounts_v1 import Value

_ACCOUNT = configuration.Configuration().read_merchant_info()
_PARENT = f"accounts/{_ACCOUNT}"


def insert_shipping_settings():
  """Inserts a ShippingSettings for a Merchant Center account."""

  # Gets OAuth Credentials.
  credentials = generate_user_credentials.main()

  # Creates a client.
  client = ShippingSettingsServiceClient(credentials=credentials)

  # Creates the request.
  request = InsertShippingSettingsRequest(
      parent=_PARENT,
      shipping_setting=ShippingSettings(
          # Etag needs to be an empty string on initial insert
          # On future inserts, call GET first to get the Etag
          # Then use the retrieved Etag on future inserts.
          # NOTE THAT ON THE INITIAL INSERT, YOUR SHIPPING SETTINGS WILL
          # NOT BE STORED, YOU HAVE TO CALL INSERT AGAIN WITH YOUR
          # RETRIEVED ETAG.
          etag="",
          services=[
              Service(
                  service_name="Canadian Postal Service",
                  active=True,
                  delivery_countries=["CA"],
                  currency_code="CAD",
                  delivery_time=DeliveryTime(
                      min_transit_days=0,
                      max_transit_days=3,
                      min_handling_days=0,
                      max_handling_days=3,
                  ),
                  rate_groups=[
                      RateGroup(
                          applicable_shipping_labels=[
                              "Oversized",
                              "Perishable",
                          ],
                          single_value=Value(price_percentage="5.4"),
                          name="Oversized and Perishable items",
                      )
                  ],
                  shipment_type=Service.ShipmentType.DELIVERY,
                  minimum_order_value={
                      "amount_micros": 10000000,
                      "currency_code": "CAD",
                  },
              )
          ],
      ),
  )

  # Makes the request and prints the inserted ShippingSettings name.
  try:
    response = client.insert_shipping_settings(request=request)
    print("Inserted ShippingSettings below")
    print(response)
    # You can apply ShippingSettings to specific products by using the
    # `shippingLabel` field on the product.
  except RuntimeError as e:
    print(e)


if __name__ == "__main__":
  insert_shipping_settings()

擷取運送設定

下列要求說明如何擷取 Merchant Center 帳戶的運送設定:

HTTP

GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings

cURL

curl \
'https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed

以下範例說明如何使用用戶端程式庫,擷取特定帳戶的運送設定資訊:

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.GetShippingSettingsRequest;
import com.google.shopping.merchant.accounts.v1.ShippingSettings;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsName;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.ShippingSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to get the ShippingSettings for a given Merchant Center account. */
public class GetShippingSettingsSample {

  public static void getShippingSettings(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    ShippingSettingsServiceSettings shippingSettingsServiceSettings =
        ShippingSettingsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates ShippingSettings name to identify ShippingSettings.
    String name =
        ShippingSettingsName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .build()
            .toString();

    // Calls the API and catches and prints any network failures/errors.
    try (ShippingSettingsServiceClient shippingSettingsServiceClient =
        ShippingSettingsServiceClient.create(shippingSettingsServiceSettings)) {

      // The name has the format: accounts/{account}/shippingSettings
      GetShippingSettingsRequest request =
          GetShippingSettingsRequest.newBuilder().setName(name).build();

      System.out.println("Sending Get ShippingSettings request:");
      ShippingSettings response = shippingSettingsServiceClient.getShippingSettings(request);

      System.out.println("Retrieved ShippingSettings below");
      System.out.println(response);
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    getShippingSettings(config);
  }
}

PHP

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\ShippingSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\GetShippingSettingsRequest;

/**
 * This class demonstrates how to get the ShippingSettings for a given Merchant Center account.
 */
class GetShippingSettings
{

    /**
     * Retrieves the shipping settings for the specified Merchant Center account.
     *
     * @param array $config The configuration data containing the account ID.
     * @return void
     */
    public static function getShippingSettings($config)
    {
        // Gets the OAuth credentials to make the request.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates options config containing credentials for the client to use.
        $options = ['credentials' => $credentials];

        // Creates a client.
        $shippingSettingsServiceClient = new ShippingSettingsServiceClient($options);

        // Creates ShippingSettings name to identify ShippingSettings.
        // The name has the format: accounts/{account}/shippingSettings
        $name = "accounts/" . $config['accountId'] . "/shippingSettings";


        // Calls the API and catches and prints any network failures/errors.
        try {
            $request = (new GetShippingSettingsRequest())
                ->setName($name);

            print "Sending Get ShippingSettings request:" . PHP_EOL;
            $response = $shippingSettingsServiceClient->getShippingSettings($request);

            print "Retrieved ShippingSettings below" . PHP_EOL;
            print_r($response);
        } catch (ApiException $e) {
            print $e->getMessage();
        }
    }

    /**
     * Helper to execute the sample.
     *
     * @return void
     */
    public function callSample(): void
    {
        $config = Config::generateConfig();
        // Makes the call to get shipping settings for the MC account.
        self::getShippingSettings($config);
    }
}

// Run the script
$sample = new GetShippingSettings();
$sample->callSample();

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()

新增倉庫設定

如要新增或更新倉庫設定,以便為帳戶儲存及處理商品目錄,請使用 accounts.shippingSettings.insert 方法。

如要使用 Merchant API 管理倉庫,請按照下列步驟操作:

  1. 如要擷取所有現有的 shippingsettingswarehouses,請使用 accounts.shippingSettings.getShippingSettings 方法發出 GET 要求。

  2. 使用 account.shippingSettings.insert 方法建立要求。將 GET 要求回應中的 shippingsettings 資源複製到插入要求。

  3. 如要使用插入呼叫新增有關倉庫的資訊,請在要求主體的 warehouses 資源中填入相關詳細資料。

  4. 執行插入要求。

下列範例要求說明如何使用 accounts.shippingSettings.insert 方法更新帳戶的倉庫設定。這項要求會設定可接受訂單的時間、開始處理訂單的時間、處理天數和運送地址。

POST https://merchantapi.googleapis.com/accounts/v1/accounts/ACCOUNT_ID/shippingSettings:insert

{
  "etag": "",
  "name": "accounts/ACCOUNT_ID/shippingSetting",
  "warehouses": [
    {
      "cutoffTime": {
        "hour": 7,
        "minute": 50
      },
      "handlingDays": 7,
      "name": "WAREHOUSE_NAME",
      "shippingAddress": {
        "streetAddress": "ADDRESS",
        "administrativeArea": "CA",
        "city": "CITY_NAME",
        "postalCode": "POSTAL_CODE",
        "regionCode": "REGION_CODE"
      }
    }
  ]
}

更改下列內容:

  • ACCOUNT_ID:Merchant Center 帳戶的專屬 ID。
  • WAREHOUSE_NAME:倉庫名稱。
  • ADDRESS:倉庫的運送地址。
  • CITY_NAME:城市、城鎮或公社。也可能包含附屬或次要地區。例如社區或郊區。
  • POSTAL_CODE:郵遞區號。例如 94043。
  • REGION_CODECLDR 國家/地區代碼。 例如「US」。

以下是成功呼叫的回應範例:

{
  "name": "accounts/ACCOUNT_ID/shippingSettings",
  "warehouses": [
    {
      "name": "WAREHOUSE_NAME",
      "shippingAddress": {
        "streetAddress": "ADDRESS",
        "city": "CITY_NAME",
        "administrativeArea": "CA",
        "postalCode": "POSTAL_CODE",
        "regionCode": "REGION_CODE"
      },
      "cutoffTime": {
        "hour": 7,
        "minute": 50
      },
      "handlingDays": "7",
      "businessDayConfig": {
        "businessDays": [
          "MONDAY",
          "TUESDAY",
          "WEDNESDAY",
          "THURSDAY",
          "FRIDAY"
        ]
      }
    }
  ],
  "etag": "OAJiUAjB0au+FBABGgR0ZXN0Ii4KAlVTGgJDQSoKQ2FsaWZvcm5pYWIFOTQwNDNyETExMXcgMzFzdCBTdHJlZXQuKgQIBxAyMAc4ATgCOAM4BDgF"
}

設定郵遞區號群組

使用 Accounts 子 API 管理 Merchant Center 帳戶的區域 (稱為 postalCodeGroups)。

postalCodeGroups 資源是分組清單,每個分組都是共用相同運送設定的多個郵遞區號清單。

使用 Merchant API 管理 postalCodeGroups,方法如下:

  1. 發出 get 呼叫,擷取所有 shippingsettingspostalCodeGroups

  2. get 呼叫中的 shippingsettings 複製到 update 呼叫。

  3. 如果運送服務未使用運送時間標籤,請從要求主體中移除下列項目。

        "transitTimeLabels": [
        "all other labels"
    ],
    
  4. update 呼叫的 postalCodeGroups 區段中,填入要使用的區域。

  5. 使用 shippingsettingspostalCodeGroups 資源發出 update 呼叫。

新增當天到貨服務

如果你有店面商品目錄資料,就可以透過 Merchant API 設定當天到貨運送服務。請參閱「在店面產品中新增店內資訊」(addlocalinventory)。

當天到貨運送服務的 shipmentTypelocal_delivery

請注意以下事項:

  • 所有 local_delivery 運送服務都視為當天到貨。
  • 你無法變更店內取貨的 deliveryTime 資訊。

如要為店面商品目錄產品設定當天到貨服務,請使用 accounts.shippingSettings.insert 方法。

以下是範例要求,可設定運送類型、storeConfig (產品出貨商店清單) 和費率群組。

POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/shippingSettings:insert

{
  "etag": "",
  "name": "accounts/ACCOUNT_ID/shippingSetting",
  "services": [
    {
      "deliveryCountries": [
        "COUNTRY_CODE"
      ],
      "serviceName": "SERVICE_NAME",
      "active": false,
      "currencyCode": "CURRENCY_CODE",
      "shipmentType": "SHIPMENT_TYPE",
      "storeConfig": {
        "cutoffConfig": {
          "localCutoffTime": {
            "hour": 7,
            "minute": 40
          }
        },
        "serviceRadius": {
          "unit": "KILOMETERS",
          "value": 40
        },
        "storeCodes": [],
        "storeServiceType": "ALL_STORES"
      },
      "rateGroups": [
        {
          "applicableShippingLabels": [
            "SHIPPING_LABEL"
          ],
          "singleValue": {
            "flatRate": {
              "amountMicros": PRICE,
              "currencyCode": "CURRENCY_CODE"
            }
          }
        }
      ]
    }
  ]
}

更改下列內容:

  • SHIPMENT_TYPE:這項服務運送訂單的地點類型,包括:
    • SHIPMENT_TYPE_UNSPECIFIED
    • DELIVERY
    • LOCAL_DELIVERY
    • COLLECTION_POINT
  • SHIPPING_LABEL:運送標籤清單,定義適用這個費率群組的產品。

以下是成功呼叫的回應範例:

{
  "name": "accounts/ACCOUNT_ID/shippingSettings",
  "services": [
    {
      "serviceName": "SERVICE_NAME",
      "active": false,
      "deliveryCountries": [
        "COUNTRY_CODE"
      ],
      "currencyCode": "CURRENCY_CODE",
      "rateGroups": [
        {
          "applicableShippingLabels": [
            "SHIPPING_LABEL"
          ],
          "singleValue": {
            "flatRate": {
              "amountMicros": "PRICE",
              "currencyCode": "CURRENCY_CODE"
            }
          }
        }
      ],
      "shipmentType": "SHIPMENT_TYPE",
      "storeConfig": {
        "storeServiceType": "ALL_STORES",
        "cutoffConfig": {
          "localCutoffTime": {
            "hour": "7",
            "minute": "40"
          },
          "noDeliveryPostCutoff": false
        },
        "serviceRadius": {
          "value": "40",
          "unit": "KILOMETERS"
        }
      }
    }
  ],
  "etag": "OAJCTQgBEAAaRwoEdGVzdBIEIgJVUxoDVVNEIggiBggHECgoACoeCAESDwoNCAESCU9WRVJTSVpFRBoJIgcIAhCAwtcvWAWSAQCaAQQIAhAo"
}

新增次日到貨服務

如果訂單是在當天到貨服務的截止時間後下訂,系統預設會安排次日到貨。

如要關閉次日到貨功能,請將 no_delivery_post_cutoff 設為 true

如果關閉次日到貨功能,運送服務只會在每天的截止時間前顯示。

只有當 shipmentTypelocal_delivery 時,才能提供次日到貨服務。

新增退貨政策

如果你透過購物廣告或自然搜尋結果列出產品,可以使用 returnpolicyonline 建立、查看、編輯或刪除線上退貨政策,並搭配下列屬性:

透過購物廣告或自然刊登銷售的產品不需要退貨地址。

詳情請參閱「設定購物廣告和自然搜尋結果的退貨政策」。

你可以使用 returnpolicyonline.create 新增退貨政策。回應會包含更新後的政策。

POST https://merchantapi.googleapis.com/v1/{ACCOUNT_ID}/returnpolicyonline