Closed markus-roe closed 4 years ago
This is not working for ORDERS as it seems.. :/
It should, use a specific (recent) api version.
It should, use a specific (recent) api version.
It seems like nextPageParameters is not working for orders..
(async () => {
let params = { limit: 10 };
let orderArray = [];
do {
const orders = await shopify.order.list(params);
orderArray.push(orders);
params = orders.nextPageParameters;
console.log('params:', params);
} while (params !== undefined);
console.log(orderArray[0].length);
res.send(orderArray);
})().catch(console.error);
I get the output:
params: undefined
10
It works.
const Shopify = require("shopify-api-node");
const shopify = new Shopify({
shopName: "quuz",
apiVersion: "2020-04",
apiKey: "b68c3a4bf44cd240511e5f4114f0be4d",
password: "2d170167fc62551920ca60fe40a5e548",
});
(async function () {
const product = await shopify.product.create({
title: "Burton Custom Freestlye 151",
body_html: "<strong>Good snowboard!</strong>",
vendor: "Burton",
product_type: "Snowboard",
});
const data = {
line_items: [
{
variant_id: product.variants[0].id,
quantity: 1,
},
],
};
await Promise.all([
shopify.order.create(data),
shopify.order.create(data),
shopify.order.create(data),
]);
const allOrders = [];
let params = { limit: 1, status: 'any' };
do {
const orders = await shopify.order.list(params);
allOrders.push(...orders);
params = orders.nextPageParameters;
console.log("params: ", params);
} while (params !== undefined);
console.log(allOrders.length);
await Promise.all([
shopify.product.delete(product.id),
...allOrders.map((order) => shopify.order.delete(order.id)),
]);
})().catch(console.error);
@lpinca, Whenever I passed page_info with updated_at_min, updated_at_max to fetch orders it returns as Bad Request(400), Otherwise it is working fine. Any help?
You have to take orders.nextPageParameters
as is and pass it to orders.list()
. page_info
is atomatically generated and included in orders.nextPageParameters
.
@lpinca, thanks I will try this.:)
Hi,
Is there a way of fetching all orders from the shopify store? The current limit is 250, how can I fetch all?