リージョン

regions サービスを使用すると、サービスを提供する地理的リージョンを作成して管理できます。 ターゲットとして使用できるものを regionalinventory および shippingsettings 提供します。地域は、郵便番号のコレクションとして定義することも、 一部の国では、事前定義済みの 地域ターゲティング。このガイドでは、 各タイプのリージョンを定義する方法と、リージョン リソースの作成方法の例 オーバーライドできますregions サービスの詳細については、以下をご覧ください。 詳しくは、リファレンス ドキュメントをご覧ください。

対象となるリージョン

リージョンを作成すると、リージョン サービスによって、 他の Content API サービスと統合します。に対して返されるレスポンス オブジェクト。 成功した regions.create 呼び出しには、次の 2 つのブール値フィールドが含まれます。 regionalInventoryEligibleshippingEligible は、 regionalinventory サービスと shippingsettings サービスでリージョンを使用できる。 できます。

regionalInventoryEligible

regionalinventory サービスを使用するには、リージョンが次の要件を満たしている必要があります。 次の条件を満たす必要があります

  • リージョンの作成時に指定する regionId には、 6 桁以上の数字を含める必要があります。
  • 地域は、地理的エリアとオンラインの最小サイズ要件を満たしている必要があります。 対象になります。

shippingEligible

shippingsettings サービスを使用するには、リージョンが次の要件を満たしている必要があります。 次の条件を満たす必要があります

  • 地域は郵便番号を使用して定義する必要があります。
  • 地域は、shippingsettings でサポートされている国に含まれている必要があります あります。

サンプル

Java で新しいリージョンを作成するために使用できるコードサンプルを次に示します。

// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package shopping.content.v2_1.samples.regions;

import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.services.content.model.Region;
import com.google.api.services.content.model.RegionPostalCodeArea;
import com.google.api.services.content.model.RegionPostalCodeAreaPostalCodeRange;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import shopping.content.v2_1.samples.ContentSample;

/**
 * Creates a region. The region created here can be used with the regional inventory service.
 * Regional availability and pricing lets you provide product availability and variable pricing
 * based on your business presence and the location of your customer base. Regional availability and
 * pricing is available for products advertised through Shopping ads on Google Search, and listed in
 * free listings on the Shopping tab.
 */
public class RegionCreateSample extends ContentSample {
  public RegionCreateSample(String[] args) throws IOException {
    super(args);
  }

  @Override
  public void execute() throws IOException {
    checkNonMCA();

    // Creates a List of Postal Code Area Postal Code Ranges.
    // This allows you to flexibly define regions as combinations of postal code
    // ranges. Each postal code range in the list has its own start and end zip code.
    List<RegionPostalCodeAreaPostalCodeRange> postalCodeRanges =
        new ArrayList<RegionPostalCodeAreaPostalCodeRange>();

    // Creates a new postal code range from two postal code values.
    // This range is equivalent to all postal codes in the USA state of New York (00501 - 14925)
    RegionPostalCodeAreaPostalCodeRange postalCodeRange =
        new RegionPostalCodeAreaPostalCodeRange().setBegin("00501").setEnd("14925");

    // Adds the NY State postal code range into the list of postal code ranges that a postal
    // code area accepts.
    postalCodeRanges.add(postalCodeRange);

    // Creates Postal Code Area for the Region that will be inserted, using the NY State postal code
    // ranges, and the US CLDR territory/country code that the postal code ranges applies to.
    RegionPostalCodeArea postalCodeArea =
        new RegionPostalCodeArea().setPostalCodes(postalCodeRanges).setRegionCode("US");

    // Creates a region with example values for displayName and postalCodeArea
    Region region = new Region().setDisplayName("NYState").setPostalCodeArea(postalCodeArea);

    // Tries to create the region, and catches any exceptions
    try {
      System.out.println("Creating region");
      Region result =
          content
              .regions()
              .create(this.config.getMerchantId().longValue(), region)
              .setRegionId("12345678") // User-defined, numeric, minimum of 6 digits
              .execute();
      System.out.println("Listing succesfully created region");
      System.out.println(result);
    } catch (GoogleJsonResponseException e) {
      checkGoogleJsonResponseException(e);
    }
  }

  public static void main(String[] args) throws IOException {
    new RegionCreateSample(args).execute();
  }
}

郵便番号を使用して地域を作成する

regions.create を使用できます。 メソッドを使用して、郵便番号のコレクションとして定義された地域を作成します。例 次の例では、米国アリゾナ州に新しいリージョンが作成されます。 郵便番号。

リージョンを作成するには、次の URL を使用して POST リクエストを行います。 body:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/regions?regionId=456789
{
  postalCodeArea: {
    regionCode: "US",
    postalCodes: [
      {
        begin: "850*",
        end: "860*"
      }
    ]
   }
}

regions のデータには 2 MB のハードリミットがあります。 と、Merchant Center アカウントごとに shippingsettings。配送と地域の設定 すべてのサブアカウントに内部的にコピーされるため、 すぐに保存容量の上限に達する場合があります。この場合、回避策として 販売者 ID 単位で regionsshippingsettings を管理できます。「 リージョンの割り当てを 2 MB の上限を超えて増やすことができます。

地域ターゲティングを使用して地域を作成する

ブラジルとロシアのリージョンの場合は、regions.create メソッドを使用することもできます。 地域ターゲティングの範囲を 1 つにまとめ、 特定できます。地域ターゲティングの種類の例としては、国、都道府県、都市、 特定の地域、空港といった場所です。ただし、regions サービスは現在のところ、 では、ブラジルでは「州」タイプ、ロシアでは「地域」タイプがサポートされています。宛先 すべてのターゲット地域 ID を含む CSV ファイルをダウンロードできる regions サービスで使用する場合は、以下をご覧ください。 ターゲット地域。以下の例では、 ブラジルの 3 つの州の地域ターゲティング ID を指定して、新しい地域を作成します。

リージョンを作成するには、次の URL を使用して POST リクエストを行います。 body:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/regions?regionId=123456
{
  geoTargetAreas: {
    geotargetCriteriaId: [20106, 20102, 20101] //Sao Paulo, Rio de Janeiro, Parana
  }
}

地域を使用して地域別の価格オーバーライドを作成する

リージョンを作成すると、regions サービスは、次のレスポンス オブジェクトを返します。 regionId と 2 つの適格性ステータス フィールドが含まれています。もし regionalInventoryEligible の値が true の場合は、regionaliventory を使用できます。 サービスを使用して、地域別に異なる価格を設定するオーバーライドを作成できます。「 以下の例では、郵便番号ベースのターゲティングを使用して地域別の価格のオーバーライドを作成します。 (regionId は「456789」)。

オーバーライドを作成するには、次の URL を使用して POST リクエストを行います。 リクエスト本文:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/products/{productId}/regionalinventory
{
  “regionId”: "456789"
  “price”: {
    value: “10”
    currency: “USD”
  },
  “availability”: “in stock”
}