简体   繁体   English

如何在 javascript 的 shopify 商店获得上个月的畅销产品?

[英]How can I get best selling products of last month on a shopify store in javascript?

I am looking for a way to get best selling products of last month on a shopify store in javascript .我正在寻找一种在javascript的 shopify 商店中获得上个月最畅销产品的方法。 I know how to get best selling products of all time.我知道如何获得有史以来最畅销的产品。 Please see the code below.请看下面的代码。

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://www.exampleshopifysite.com/collections/all/products.json?sort-by=best-selling",
  "method": "GET",
  "headers": {
    "Cache-Control": "no-cache"

  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

The url you've provided doesn't seem to provide relevant information.您提供的 url 似乎没有提供相关信息。

But you can extract below information.但是您可以提取以下信息。

id,title,handle,body_html,published_at,created_at,updated_at,vendor,product_type,tags,variants,images,options

Example script ( link to fiddle )示例脚本(链接到小提琴

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://spritude.com/collections/all/products.json?sort-by=best-selling",
  "method": "GET",
}

$.ajax(settings).done(function (response) {
  response.products.slice(0, 10).forEach(product => {
    console.log(`ID: ${product.id}`);
    console.log(`TITLE: ${product.title}`);
    console.log(`HANDLE: ${product.handle}`);
    console.log(`PUBLISHED AT: ${product.published_at}`);
    console.log(`CREATED AT: ${product.created_at}`);
    console.log(`UPDATED AT: ${product.updated_at}`);
    console.log(`VENDOR: ${product.vendor}`);
    console.log(`PRODUCT TYPE: ${product.product_type}`);
    console.log(`TAGS: ${product.tags}`);
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 按最畅销商品对Shopify集合进行排序,以用于json - Sort a Shopify collection by best selling for use in json fullcalendar:我怎样才能获得相关查看月份的第一天和最后一天(而不是上一个\\下个月的天) - fullcalendar: how can i get the first and last day of the relevant viewed month (and not the days of of the prev \ next month) 如何使用node和express在shopify app前端获取当前商店详细信息 - How can I get current store details in shopify app front-end using node and express 如何为我的应用程序获取 Shopify 商店产品的所有数据? - How can I get all the data of a Shopify store product for my app? 如何在javascript中获取最后一小时,上个月和昨天? - How to get last hour, last month and yesterday in javascript? 如何获取JSON数据中上周或上个月的数据? - How can I get data of last week or last month in JSON data? 如何使用 JavaScript 以大写字母形式获取当前月份名称 - How can I get the current month name in capitals with JavaScript Shopify 获取所有产品 - Shopify get all products 获取本月最后一个星期日 - JavaScript - Get last Sunday in Month - JavaScript 如何通过使用JavaScript输入开放日期和持续时间来获取未来的日期月份和年份 - How can I get future date month and year by inputting opening date and duration month using JavaScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM