regions
サービスを使用すると、regionalinventory
サービスと shippingsettings
サービスの両方でターゲットとして使用できる地理的リージョンを作成して管理できます。地域は、郵便番号のコレクションとして定義できます。一部の国では、定義済みの地域ターゲティングを使用して定義することもできます。このガイドでは、各タイプの地域を定義する方法と、地域別の料金のオーバーライドを作成する方法の例を示します。使用可能なすべてのメソッドとパラメータなど、regions
サービスの詳細については、リファレンス ドキュメントをご覧ください。
対象となるリージョン
地域を作成すると、その地域を他の Content API サービスで使用できるかどうかが決まります。regions.create
呼び出しが成功すると返されるレスポンス オブジェクトには、regionalInventoryEligible
と shippingEligible
の 2 つのブール値フィールドが含まれます。これらは、それぞれ 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
リクエストを送信します。
https://shoppingcontent.googleapis.com/content/v2.1/merchantId/regions?regionId=456789
{
postalCodeArea: {
regionCode: "US",
postalCodes: [
{
begin: "850*",
end: "860*"
}
]
}
}
regions
と shippingsettings
のデータには、Merchant Center アカウントごとに 2 MB のハードリミットがあります。送料と地域の設定は、MCA からそのすべてのサブアカウントに内部的にコピーされるため、MCA のサイズが大きい場合は、すぐに保存容量の上限に達する可能性があります。この場合は、販売者 ID レベルで regions
と shippingsettings
を管理することが回避策です。リージョンの割り当てを 2 MB の上限を超えて増やす方法はありません。
地域ターゲティングを使用して地域を作成する
ブラジルとロシアの地域の場合、regions.create
メソッドを使用して、地域ターゲティングの集合として定義された地域(事前定義の地域)を作成することもできます。地域ターゲティングの種類には、国、都道府県、都市、近隣地域、空港などがあります。ただし、regions
サービスは現在、ブラジルの「州」タイプとロシアの「地域」タイプのみをサポートしています。regions
サービスで使用できる地域ターゲティングを含むすべての地域ターゲティング ID の CSV ファイルをダウンロードするには、地域ターゲティングをご覧ください。以下の例では、ブラジルの 3 つの州の地域ターゲティング ID を指定して新しい地域を作成します。
リージョンを作成するには、次の URL とリクエスト本文を使用して POST
リクエストを行います。
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”
}