Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to add Order History Page for Customer?

How to add Order History Page for Customer?

YanuarCT
Visitor
1 0 0

Hello, i require order history page for my project

 

From the Sales Channels, it seems that it only has home page, product page, and cart page

is there a way to add order history page for customer?

Reply 1 (1)

Liam
Community Manager
3108 344 899

Hi YanuarCT,

 

To get information on orders in Shopify, you can use the Orders API. The Orders API allows you to retrieve, create, and update orders in a Shopify store.

To retrieve order information, you can use the `GET /admin/api/2021-07/orders.json` endpoint. This endpoint returns a list of orders, along with their associated information, such as customer details, line items, and shipping information.

 

Here's an example of how to retrieve a list of orders using the Orders API in Node.js:

const request = require('request');

// Replace {shopify_store_url} and {access_token} with your store's URL and access token
const url = `https://{shopify_store_url}/admin/api/2021-07/orders.json`;
const headers = {
  'X-Shopify-Access-Token': '{access_token}',
};

request.get({ url, headers }, (error, response, body) => {
  if (error) {
    console.error('Failed to retrieve orders:', error);
    return;
  }

  if (response.statusCode !== 200) {
    console.error('Failed to retrieve orders:', body);
    return;
  }

  const orders = JSON.parse(body).orders;
  // Do something with the orders
});

This example uses the request library to make a GET request to the Orders API endpoint. The headers object includes the access token required to authenticate the request. The response body is parsed as JSON, and the orders array is extracted from the response. You can then do something with the orders array, such as analyzing the order histories of customers.

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog