با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
سرویس محتوای خرید به شما امکان میدهد از Google Content API برای خرید در Apps Script استفاده کنید. این API به کاربران Google Merchant Center امکان آپلود و مدیریت لیست محصولات خود و مدیریت حساب های Merchant Center خود را می دهد.
برای اطلاعات دقیق درباره این سرویس، به مستندات مرجع Google Content API for Shopping مراجعه کنید. مانند همه سرویسهای پیشرفته در Apps Script، سرویس محتوای خرید از همان اشیا، روشها و پارامترهای API عمومی استفاده میکند.
مرجع
برای اطلاعات دقیق در مورد این سرویس، به مستندات مرجع Google Content API for Shopping API مراجعه کنید. مانند همه سرویسهای پیشرفته در Apps Script، سرویس برگههای پیشرفته از همان اشیا، روشها و پارامترهای API عمومی استفاده میکند. برای اطلاعات بیشتر، نحوه تعیین امضای روش را ببینید.
/** * Inserts a product into the products list. Logs the API response. */functionproductInsert(){constmerchantId=123456;// Replace this with your Merchant Center ID.// Create a product resource and insert itconstproductResource={'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 exceptionsconsole.log('Failed with error: $s',e.error);}}
لیست محصولات
این مثال نشان می دهد که چگونه محصولات خود را برای یک حساب مرکز تجاری معین فهرست کنید.
/** * Lists the products for a given merchant. */functionproductList(){constmerchantId=123456;// Replace this with your Merchant Center ID.letpageToken;letpageNum=1;constmaxResults=10;try{do{constproducts=ShoppingContent.Products.list(merchantId,{pageToken:pageToken,maxResults:maxResults});console.log('Page '+pageNum);if(products.resources){for(leti=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 exceptionsconsole.log('Failed with error: $s',e.error);}}
محصولات درج دسته ای
این مثال از Products.custombatch برای درج سه محصول به طور همزمان استفاده می کند.
/** * 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. */functioncustombatch(productResource1,productResource2,productResource3){constmerchantId=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{constresponse=ShoppingContent.Products.custombatch(custombatchResource);console.log(response);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log('Failed with error: $s',e.error);}}
مالیات های سطح حساب را به روز کنید
این کد نمونه از Accounttax برای بهروزرسانی اطلاعات مالیاتی سطح حساب برای حساب Merchant Center استفاده میکند. برای اطلاعات بیشتر درباره مالیات در سطح حساب و حمل و نقل، راهنمای API ما را ببینید.
/** * Updates content account tax information. * Logs the API response. */functionupdateAccountTax(){// Replace this with your Merchant Center ID.constmerchantId=123456;// Replace this with the account that you are updating taxes for.constaccountId=123456;try{constaccounttax=ShoppingContent.Accounttax.get(merchantId,accountId);console.log(accounttax);consttaxInfo={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 exceptionsconsole.log('Failed with error: $s',e.error);}}
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Shopping Content Service lets you manage Google Merchant Center product listings and accounts within Apps Script using the Google Content API for Shopping.\u003c/p\u003e\n"],["\u003cp\u003eThis is an advanced service that requires enabling before use and mirrors the functionality of the public API.\u003c/p\u003e\n"],["\u003cp\u003eProvided code samples demonstrate common tasks like inserting, listing, and batch-updating products, as well as updating account-level tax information.\u003c/p\u003e\n"],["\u003cp\u003eFor comprehensive details, consult the Google Content API for Shopping reference documentation and support guide linked within the content.\u003c/p\u003e\n"]]],[],null,[]]