কেনাকাটা বিষয়বস্তু পরিষেবা

প্রোডাক্ট লিস্টিং এবং মার্চেন্ট সেন্টার অ্যাকাউন্ট পরিচালনা করার জন্য শপিং ইন অ্যাপস স্ক্রিপ্ট।

শপিং কন্টেন্ট সার্ভিস আপনাকে গুগল অ্যাপস স্ক্রিপ্টে শপিং-এর জন্য গুগল কন্টেন্ট এপিআই ব্যবহার করার সুযোগ দেয়। এই এপিআই গুগল মার্চেন্ট সেন্টার ব্যবহারকারীদের তাদের পণ্যের তালিকা আপলোড ও পরিচালনা করতে এবং তাদের মার্চেন্ট সেন্টার অ্যাকাউন্টগুলো পরিচালনা করতে সক্ষম করে।

এই পরিষেবা সম্পর্কে বিস্তারিত তথ্যের জন্য, Google Content API for Shopping-এর রেফারেন্স ডকুমেন্টেশন দেখুন। Apps Script-এর অন্যান্য সকল অ্যাডভান্সড সার্ভিসের মতোই, Shopping Content Service পাবলিক API-এর ব্যবহৃত একই অবজেক্ট, মেথড এবং প্যারামিটারসমূহ ব্যবহার করে।

এটি একটি উন্নত পরিষেবা যা ব্যবহারের আগে সক্রিয় করতে হবে।

রেফারেন্স

এই পরিষেবা সম্পর্কে বিস্তারিত তথ্যের জন্য, Google Content API for Shopping API-এর রেফারেন্স ডকুমেন্টেশন দেখুন। Apps Script-এর সমস্ত অ্যাডভান্সড পরিষেবার মতো, Shopping Content পরিষেবাটিও পাবলিক API-এর মতোই একই অবজেক্ট, মেথড এবং প্যারামিটার ব্যবহার করে। আরও তথ্যের জন্য, "How method signatures are determined " দেখুন।

সমস্যা জানাতে এবং অন্যান্য সহায়তা পেতে, Google Content API for Shopping সাপোর্ট গাইডটি দেখুন।

নমুনা কোড

এখন আমরা শপিং কন্টেন্ট সার্ভিসের কয়েকটি ফিচার কীভাবে ব্যবহার করতে হয় তা দেখাবো।

পণ্য ঢোকান

এই উদাহরণটি দেখায় কিভাবে একটি নির্দিষ্ট মার্চেন্ট সেন্টার অ্যাকাউন্টে একটিমাত্র পণ্য যুক্ত করতে হয়।

advanced/shoppingContent.gs
/**
 * Inserts a product into the products list. Logs the API response.
 */
function productInsert() {
  const merchantId = 123456; // Replace this with your Merchant Center ID.
  // Create a product resource and insert it
  const productResource = {
    offerId: "book123",
    title: "A Tale of Two Cities",
    description: "A classic novel about the French Revolution",
    link: "http://my-book-shop.com/tale-of-two-cities.html",
    imageLink: "http://my-book-shop.com/tale-of-two-cities.jpg",
    contentLanguage: "en",
    targetCountry: "US",
    channel: "online",
    availability: "in stock",
    condition: "new",
    googleProductCategory: "Media > Books",
    productType: "Media > Books",
    gtin: "9780007350896",
    price: {
      value: "2.50",
      currency: "USD",
    },
    shipping: [
      {
        country: "US",
        service: "Standard shipping",
        price: {
          value: "0.99",
          currency: "USD",
        },
      },
    ],
    shippingWeight: {
      value: "2",
      unit: "pounds",
    },
  };

  try {
    response = ShoppingContent.Products.insert(productResource, merchantId);
    // RESTful insert returns the JSON object as a response.
    console.log(response);
  } catch (e) {
    // TODO (Developer) - Handle exceptions
    console.log("Failed with error: $s", e.error);
  }
}

পণ্যের তালিকা

এই উদাহরণটি দেখায় কিভাবে একটি নির্দিষ্ট মার্চেন্ট সেন্টার অ্যাকাউন্টের জন্য আপনার পণ্য তালিকাভুক্ত করতে হয়।

advanced/shoppingContent.gs
/**
 * Lists the products for a given merchant.
 */
function productList() {
  const merchantId = 123456; // Replace this with your Merchant Center ID.
  let pageToken;
  let pageNum = 1;
  const maxResults = 10;
  try {
    do {
      const products = ShoppingContent.Products.list(merchantId, {
        pageToken: pageToken,
        maxResults: maxResults,
      });
      console.log(`Page ${pageNum}`);
      if (products.resources) {
        for (let i = 0; i < products.resources.length; i++) {
          console.log(`Item [${i}] ==> ${products.resources[i]}`);
        }
      } else {
        console.log(`No more products in account ${merchantId}`);
      }
      pageToken = products.nextPageToken;
      pageNum++;
    } while (pageToken);
  } catch (e) {
    // TODO (Developer) - Handle exceptions
    console.log("Failed with error: $s", e.error);
  }
}

ব্যাচ ইনসার্ট পণ্য

এই উদাহরণটিতে একই সাথে তিনটি পণ্য যুক্ত করার জন্য Products.custombatch ব্যবহার করা হয়েছে।

advanced/shoppingContent.gs
/**
 * Batch updates products. Logs the response.
 * @param  {object} productResource1 The first product resource.
 * @param  {object} productResource2 The second product resource.
 * @param  {object} productResource3 The third product resource.
 */
function custombatch(productResource1, productResource2, productResource3) {
  const merchantId = 123456; // Replace this with your Merchant Center ID.
  custombatchResource = {
    entries: [
      {
        batchId: 1,
        merchantId: merchantId,
        method: "insert",
        productId: "book124",
        product: productResource1,
      },
      {
        batchId: 2,
        merchantId: merchantId,
        method: "insert",
        productId: "book125",
        product: productResource2,
      },
      {
        batchId: 3,
        merchantId: merchantId,
        method: "insert",
        productId: "book126",
        product: productResource3,
      },
    ],
  };
  try {
    const response = ShoppingContent.Products.custombatch(custombatchResource);
    console.log(response);
  } catch (e) {
    // TODO (Developer) - Handle exceptions
    console.log("Failed with error: $s", e.error);
  }
}

অ্যাকাউন্ট-স্তরের কর আপডেট করুন

এই নমুনা কোডটি একটি মার্চেন্ট সেন্টার অ্যাকাউন্টের অ্যাকাউন্ট-স্তরের কর তথ্য আপডেট করতে Accounttax ব্যবহার করে। অ্যাকাউন্ট-স্তরের কর এবং শিপিং সম্পর্কে আরও তথ্যের জন্য আমাদের API গাইড দেখুন।

advanced/shoppingContent.gs
/**
 * Updates content account tax information.
 * Logs the API response.
 */
function updateAccountTax() {
  // Replace this with your Merchant Center ID.
  const merchantId = 123456;

  // Replace this with the account that you are updating taxes for.
  const accountId = 123456;

  try {
    const accounttax = ShoppingContent.Accounttax.get(merchantId, accountId);
    console.log(accounttax);

    const taxInfo = {
      accountId: accountId,
      rules: [
        {
          useGlobalRate: true,
          locationId: 21135,
          shippingTaxed: true,
          country: "US",
        },
        {
          ratePercent: 3,
          locationId: 21136,
          country: "US",
        },
        {
          ratePercent: 2,
          locationId: 21160,
          shippingTaxed: true,
          country: "US",
        },
      ],
    };

    console.log(
      ShoppingContent.Accounttax.update(taxInfo, merchantId, accountId),
    );
  } catch (e) {
    // TODO (Developer) - Handle exceptions
    console.log("Failed with error: $s", e.error);
  }
}