Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
As the title says... I'm trying to get a customer orders. Is there any way to do so with using the shopify api node?
I see a method called orders on the customer but it says "id". I've passed it all the id's that was returned in the customer object.
Here the link to the documentation.
https://www.npmjs.com/package/shopify-api-node
Thanks.
Can you provide the code snippet you're using?
Yes I can. What id is being passed in the orders method?
It should be the customer numerical Id (e.g. 419331998712) according to this:
https://github.com/MONEI/Shopify-api-node/blob/master/resources/customer.js#L67
What sort of response are you getting back?
Any customer id I give the method I get back a blank array. But, I know the customer exists. Here's my customer id (1549978173504) that I get when I do a customer search with this method
shopify.customer .search({ first_name: req.body.searchParam }) .then(search => { console.log(search) return res.status(200).json({ msg: search }) }) .catch(err => { return res.status(400).json({ msg: err }) });
shopify.customer .orders(1549978173504) .then((orders) => res.status(200).json({msg: orders })) .catch((err) => console.error(err));
what you are lacking is a necessary query paramater `status` - you need to set it to `any` so that the response will return all customer's orders. like so:
shopify.customer .orders(1549978173504, { status: 'any' }) .then((orders) => res.status(200).json({msg: orders })) .catch((err) => console.error(err));
Hi,
I've tried the code as you suggested, but I still get a 401 Unauthorized Error.
Code:
shopify.customer
.orders( customer.id, { status: 'any' })
.then((orders) => res.status(200).json({msg: orders }))
.catch((err) => console.error(err));
I'm using this in the GDPR webhook
app.post('/customers/data_request', async(req, res) => {});
and customer.id contains the Customer ID for whom data is requested.
Any help is appreciated.
Thanks,
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025