Order details

rabinparajuli
Shopify Partner
4 0 0

I want to get customer details/order details in my application from the shopify store. How can i do that?

Replies 3 (3)
Nia
Shopify Staff
Shopify Staff
531 37 75

Hi @rabinparajuli , 
 
Thanks for reaching out here! I'd like to gather a bit more context so we understand what you're after. 
 
What application are you referring to? Would you perhaps be able to explain abit more as to what you're wanting to achieve?
 
We can go from there! 

Nia | Social Care @ 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 the Shopify Help Center or the Shopify Blog

rabinparajuli
Shopify Partner
4 0 0

Hi Nia, 

Thank you for reaching out to me. Well the application i am developing is for delivery. So i want to get customer details on my application once they have purchased something from the store. 

 

 

rabinparajuli
Shopify Partner
4 0 0

Hello Nia, 

i tried with this code but didn't work for me.

// src/components/OrderList.js
import React, { useEffect, useState } from 'react';
import shopifyApi from './Shopifyapi';

function OrderList() {
  const [orderDetails, setOrderDetails] = useState([]);

  useEffect(() => {
    shopifyApi.get('/admin/api/2023-10/orders.json')
      .then(response => {
        // Extract the 'id' property from each order object
        const orderIds = response.data.orders.map(order => order.id);
        setOrderDetails(orderIds);
      })
      .catch(error => {
        console.error('Error fetching order data:', error);
      });
  }, []);

export default OrderList;