इलाके

regions सेवा की मदद से, ऐसे भौगोलिक क्षेत्र बनाए और मैनेज किए जा सकते हैं आप दोनों के साथ लक्ष्यों के रूप में regionalinventory और shippingsettings सेवाओं. क्षेत्रों को पिन कोड के संग्रह के तौर पर तय किया जा सकता है या पहले से तय भौगोलिक टारगेट. इस गाइड में हर तरह के क्षेत्र को तय करने के उदाहरण और क्षेत्र तय करने के तरीके के बारे में जानकारी कीमत में बदलाव करना. regions सेवा के बारे में ज़्यादा जानकारी के लिए, सभी उपलब्ध तरीकों और पैरामीटर के साथ, रेफ़रंस दस्तावेज़ देखें.

क्षेत्र के लिए ज़रूरी शर्तें

जब कोई क्षेत्र बनाया जाता है, तो क्षेत्र सेवा यह तय करती है कि आपके पास Content API की अन्य सेवाओं वाले अपने इलाके के बारे में ज़्यादा जानें. इसके लिए रिस्पॉन्स ऑब्जेक्ट लौटाया गया सफल regions.create कॉल में दो बूलियन फ़ील्ड शामिल हैं, regionalInventoryEligible और shippingEligible. इनसे पता चलता है कि 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 का इस्तेमाल कर सकते हैं पिन कोड के संग्रह के तौर पर परिभाषित क्षेत्र बनाने का तरीका. उदाहरण के लिए नीचे दिए गए लिंक, लिंक, लिंक वगैरह की रेंज तय करके अमेरिका के एरिज़ोना राज्य के लिए एक नया क्षेत्र तय करते हैं पिन कोड.

क्षेत्र बनाने के लिए, इस यूआरएल का इस्तेमाल करके POST से अनुरोध करें और इसके लिए अनुरोध करें मुख्य भाग:

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

regions के लिए 2 एमबी डेटा की ज़्यादा से ज़्यादा सीमा है और हर Merchant Center खाते के लिए shippingsettings. शिपिंग और क्षेत्र की सेटिंग एक एमसीए से उसके सभी उप-खातों में, अंदरूनी तौर पर कॉपी की जाती है. इसलिए, बड़ी एमसीए, तो हो सकता है कि आपका स्टोरेज जल्द ही भर जाए. इस मामले में, समस्या का हल है मर्चेंट आईडी लेवल पर regions और shippingsettings को मैनेज करने के लिए. कोई नहीं क्षेत्रों का कोटा 2 एमबी से ज़्यादा बढ़ाने का तरीका.

भौगोलिक टारगेट का इस्तेमाल करके क्षेत्र बनाना

ब्राज़ील और रूस के इलाकों के लिए, regions.create तरीके का भी इस्तेमाल किया जा सकता है ताकि भौगोलिक टारगेट के कलेक्शन को एक क्षेत्र तय किया जा सके. इन लक्ष्यों को भौगोलिक क्षेत्र. इलाके के हिसाब से टारगेट करने के टाइप के उदाहरणों में देश, राज्य, शहर, आस-पास और हवाई अड्डे. हालांकि, regions सेवा फ़िलहाल सिर्फ़ ब्राज़ील के लिए “राज्य” और रूस के लिए “क्षेत्र” टाइप का इस्तेमाल किया जा सकता है. यहां की यात्रा पर हूं सभी भौगोलिक लक्ष्य आईडी की CSV फ़ाइल डाउनलोड करें. इसमें वे भौगोलिक लक्ष्य भी शामिल हैं जिन्हें regions सेवा के साथ इस्तेमाल किया गया है, देखें जियोटारगेट. नीचे दिए गए उदाहरण से एक नया क्षेत्र बनाने के लिए.

क्षेत्र बनाने के लिए, इस यूआरएल का इस्तेमाल करके 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 और दो ज़रूरी शर्तें स्थिति वाले फ़ील्ड शामिल होते हैं. अगर regionalInventoryEligible की वैल्यू true है, regionaliventory का इस्तेमाल किया जा सकता है सेवा का इस्तेमाल करें, जो क्षेत्र के लिए अलग कीमत सेट करती है. कॉन्टेंट बनाने नीचे दिए गए उदाहरण में पिन कोड के हिसाब से, क्षेत्र के हिसाब से कीमत को बदला गया है ऊपर दिए गए उदाहरण में बनाया गया क्षेत्र, जिसमें “456789” का regionId है.

बदलाव करने के लिए, इस यूआरएल का इस्तेमाल करके POST अनुरोध करें और अनुरोध का मुख्य भाग:

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