[英]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.