지역

regions 서비스를 사용하면 regionalinventoryshippingsettings 서비스 모두의 대상으로 사용할 수 있는 지리적 리전을 만들고 관리할 수 있습니다. 지역을 우편번호 모음으로 정의하거나 일부 국가에서는 사전 정의된 지역 타겟을 사용하여 정의할 수 있습니다. 이 가이드에서는 각 지역 유형을 정의하는 방법과 지역별 가격 재정의를 만드는 방법을 보여주는 예시를 제공합니다. 사용 가능한 모든 메서드와 매개변수를 비롯하여 regions 서비스에 대한 자세한 내용은 참조 문서를 확인하세요.

지역 자격요건

리전을 만들 때 리전 서비스는 해당 리전을 다른 Content API 서비스와 함께 사용할 수 있는지 여부를 결정합니다. 성공적인 regions.create 호출에 대해 반환되는 응답 객체에는 각각 regionalinventoryshippingsettings 서비스와 함께 해당 리전을 사용할 수 있는지 여부를 나타내는 두 개의 불리언 필드인 regionalInventoryEligibleshippingEligible가 포함됩니다.

regionalInventoryEligible

regionalinventory 서비스와 함께 사용하려면 리전이 다음 기준을 충족해야 합니다.

  • 리전을 만들 때 지정하는 regionId은 숫자만 포함해야 하며 최소 6자리 숫자를 포함해야 합니다.
  • 지역은 지리적 영역 및 온라인 인구에 대한 최소 크기 요구사항을 충족해야 합니다.

shippingEligible

shippingsettings 서비스와 함께 사용하려면 리전이 다음 기준을 충족해야 합니다.

  • 지역은 우편번호를 사용하여 정의해야 합니다.
  • 리전은 shippingsettings 서비스에서 지원하는 국가에 속해 있어야 합니다.

샘플

다음은 자바로 새 지역을 만드는 데 사용할 수 있는 전체 코드 샘플입니다.

// 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*"
      }
    ]
   }
}

판매자 센터 계정당 regionsshippingsettings의 데이터 한도는 2MB입니다. 배송 및 리전 설정은 내부적으로 MCA에서 모든 하위 계정으로 복사되므로 대규모 MCA의 경우 스토리지 한도에 빠르게 도달할 수 있습니다. 이 경우 해결 방법은 판매자 ID 수준에서 regionsshippingsettings를 관리하는 것입니다. 리전 할당량을 2MB 한도를 초과하여 늘릴 방법은 없습니다.

지역 타겟을 사용하여 지역 만들기

브라질과 러시아 지역의 경우 regions.create 메서드를 사용하여 사전 정의된 지역인 지역 타겟의 모음으로 정의된 지역을 만들 수도 있습니다. 지역 타겟팅 유형의 예로는 국가, 주, 도시, 인근 지역, 공항이 있습니다. 그러나 regions 서비스는 현재 브라질의 'State' 유형과 러시아의 'Region' 유형만 지원합니다. 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”
}