Im using wc rest api with nodejs and when trying to post new order via "orders" with method POST, I simply get response containing all the existing orders..
Even if not providing any request body, or providing false request body - same response always:
WooCommerce.post("orders", {
customer_id: 2000,
})
.then((response) => {
res.send(response.data);
})
.catch((err) => {
res.status(500).send(e.response.data);
});
Response:
[
{
"id": 32941,
"parent_id": 0,
"status": "pending",
"currency": "ILS",
"version": "5.3.1",
"prices_include_tax": false,
"date_created": "2022-02-17T11:23:28",
"date_modified": "2022-02-17T11:24:39",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "0.00",
"total": "9.90",
"total_tax": "0.00",
"customer_id": 110,
"order_key": "wc_order_Gv1ZIlKqqMKFt",
"billing": {
"first_name": "",
"last_name": "",
"company": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"postcode": "",
"country": "",
"email": "raz#king.com",
"phone": ""
},
"shipping": {
"first_name": "",
"last_name": "",
"company": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"postcode": "",
"country": ""
},
"payment_method": "",
"payment_method_title": "",
"transaction_id": "",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "admin",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"cart_hash": "",
"number": "32941",
"meta_data": [],
"line_items": [
{
"id": 3267,
"name": "מלפפון",
"product_id": 32409,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "9.90",
"subtotal_tax": "0.00",
"total": "9.90",
"total_tax": "0.00",
"taxes": [],
"meta_data": [],
"sku": "10864",
"price": 9.9,
"parent_name": null
}
],
"tax_lines": [],
"shipping_lines": [],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"date_created_gmt": "2022-02-17T09:23:28",
"date_modified_gmt": "2022-02-17T09:24:39",
"date_completed_gmt": null,
"date_paid_gmt": null,
"currency_symbol": "₪",
"_links": {
"self": [
{
"href": "https://XXX.XXX.XXX/wp-json/wc/v3/orders/32941"
}
],
"collection": [
{
"href": "https://XXX.XXX.XXX/wp-json/wc/v3/orders"
}
],
"customer": [
{
"href": "https://XXX.XXX.XXX/wp-json/wc/v3/customers/110"
}
]
}
}
]
Please be aware that I've masked some data :)
WooCommerce.post("orders?_method=POST", order)
.then((response) => {
res.send(response.data);
})
.catch((e) => {
console.log(e);
res
.status(e?.response?.status || 500)
.send(e?.response?.statusText || e?.response?.data || "Error!");
});
Found on google that need to use native http methods like get or post and pass in the param ?_method=METHOD to define what method to use....
Working.
Hi I am calling an API using axios. it is returning data. that data I am using to populate a table. but it is giving error.
const [response, setResponse] = useState([]);
const [flag, setFlag] = useState(false);
await axios.get(`http://localhost:3000/api/certificates?page=${page}`,{
params: param,
}).then(res=>{
console.log(res.data);
setResponse(res.data);
setFlag(true);
})
then I am using response into table to populate data. table will be populated only if flag become true.
<div className="col-md-10 container">
{ flag && (
<table className="table table-bordered ">
<tbody>
{ flag && response.map((certificate: Certificate, index: number) => (
<tr>
<td>{certificate.certifcateNo}</td>
<td>{certificate.protoCOlNo}</td>
</tr>
}
</tbody>
</table>
</div>
My API is returning below output from postman
{
"data": [
{
"id": "cace4b0c-2836-412a-be60-78f726917ff6",
"createdAt": "2021-12-03T21:06:14.540Z",
"modifiedAt": "2021-12-03T21:06:14.540Z",
"deletedAt": null,
"certificateNo": 1,
"requestStatus": "DRAFT",
"sponser": "Onkar",
"address": "JBP",
"address2": "BUSINESS BAY",
"zipCode": "40013",
"city": "MH",
"protoColNo": "123",
"molecules": "Shweta",
"unAuthMolecule": "NO",
"phaseOfTrial": 1,
"noOfSubjects": "5",
"startDate": "2011-11-09",
"endDate": "2012-11-09",
"personInCharge": "Deepali",
"country": "India",
"comments": "I am Genius",
"attachedFile": "string"
},
{
"id": "91dfa4e3-d7f7-4671-b3e3-ba90c6454a1a",
"createdAt": "2021-12-03T21:06:22.690Z",
"modifiedAt": "2021-12-03T21:06:22.690Z",
"deletedAt": null,
"certificateNo": 2,
"requestStatus": "DRAFT",
"sponser": "Onkar",
"address": "JBP",
"address2": "BUSINESS BAY",
"zipCode": "40013",
"city": "MH",
"protoColNo": "123",
"molecules": "Shweta",
"unAuthMolecule": "NO",
"phaseOfTrial": 1,
"noOfSubjects": "5",
"startDate": "2011-11-09",
"endDate": "2012-11-09",
"personInCharge": "Deepali",
"country": "India",
"comments": "I am Genius",
"attachedFile": "string"
},
{
"id": "c84d7bce-cdcb-4984-89a2-ad2291651867",
"createdAt": "2021-12-03T21:06:23.398Z",
"modifiedAt": "2021-12-03T21:06:23.398Z",
"deletedAt": null,
"certificateNo": 3,
"requestStatus": "DRAFT",
"sponser": "Onkar",
"address": "JBP",
"address2": "BUSINESS BAY",
"zipCode": "40013",
"city": "MH",
"protoColNo": "123",
"molecules": "Shweta",
"unAuthMolecule": "NO",
"phaseOfTrial": 1,
"noOfSubjects": "5",
"startDate": "2011-11-09",
"endDate": "2012-11-09",
"personInCharge": "Deepali",
"country": "India",
"comments": "I am Genius",
"attachedFile": "string"
},
{
"id": "0755d2f9-50df-4b5a-a863-d173a12b45b5",
"createdAt": "2021-12-03T21:06:23.762Z",
"modifiedAt": "2021-12-03T21:06:23.762Z",
"deletedAt": null,
"certificateNo": 4,
"requestStatus": "DRAFT",
"sponser": "Onkar",
"address": "JBP",
"address2": "BUSINESS BAY",
"zipCode": "40013",
"city": "MH",
"protoColNo": "123",
"molecules": "Shweta",
"unAuthMolecule": "NO",
"phaseOfTrial": 1,
"noOfSubjects": "5",
"startDate": "2011-11-09",
"endDate": "2012-11-09",
"personInCharge": "Deepali",
"country": "India",
"comments": "I am Genius",
"attachedFile": "string"
},
{
"id": "05c1ce23-eaf6-4ff9-aa5c-5f0554a22205",
"createdAt": "2021-12-03T21:06:24.032Z",
"modifiedAt": "2021-12-03T21:06:24.032Z",
"deletedAt": null,
"certificateNo": 5,
"requestStatus": "DRAFT",
"sponser": "Onkar",
"address": "JBP",
"address2": "BUSINESS BAY",
"zipCode": "40013",
"city": "MH",
"protoColNo": "123",
"molecules": "Shweta",
"unAuthMolecule": "NO",
"phaseOfTrial": 1,
"noOfSubjects": "5",
"startDate": "2011-11-09",
"endDate": "2012-11-09",
"personInCharge": "Deepali",
"country": "India",
"comments": "I am Genius",
"attachedFile": "string"
}
],
"meta": {
"total": 16,
"page": "1",
"last_page": 4
}
}
what mistake I am doing?
Idk if you just wrote your code too quickly, but you are missing closing parentheses.
{ flag && response.map((certificate: Certificate, index: number) => (
<tr>
<td>{certificate.certifcateNo}</td>
<td>{certificate.protoCOlNo}</td>
</tr>
))} <-- here
const {data} = await axios.get(`http://localhost:3000/api/certificates?page=${page}`,{
params: param,
})
console.log(data.data);
setResponse(data.data);
setFlag(true);
So i've been using the microsoft bookings Beta Api getting the List from this URL:
GET https://graph.microsoft.com/beta/bookingBusinesses/Contosolunchdelivery#M365B489948.onmicrosoft.com/appointments
it works fine except i need to get the start -> dateTime and end -> dateTime for the specific appointment but its returning wrong start dates? even though when i go to bookings i clearly put the start time.
This is what the JSON-Example should looks like:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#bookingBusinesses('Contosolunchdelivery%40M365B489948.onmicrosoft.com')/appointments",
"value": [
{
"id": "AAMkADKoAAA=",
"selfServiceAppointmentId": "00000000-0000-0000-0000-000000000000",
"customerId": "829e3cb5-3d4d-4319-a8de-1953aedaa166",
"customerName": "Bob Kelly",
"customerEmailAddress": "bobk#tailspintoys.com",
"customerPhone": "213-555-0108",
"customerNotes": null,
"serviceId": "57da6774-a087-4d69-b0e6-6fb82c339976",
"serviceName": "Catered bento",
"duration": "PT30M",
"preBuffer": "PT5M",
"postBuffer": "PT10M",
"priceType": "fixedPrice",
"price": 10,
"serviceNotes": null,
"optOutOfCustomerEmail": false,
"staffMemberIds": [],
"invoiceAmount": 10,
"invoiceId": "1002",
"invoiceStatus": "open",
"invoiceUrl": "theInvoiceUrl",
"customerLocation": {
"displayName": "Customer",
"locationEmailAddress": null,
"locationUri": "",
"locationType": null,
"uniqueId": null,
"uniqueIdType": null,
"address": {
"type": "home",
"postOfficeBox": "",
"street": "",
"city": "",
"state": "",
"countryOrRegion": "",
"postalCode": ""
},
"coordinates": {
"altitude": null,
"latitude": null,
"longitude": null,
"accuracy": null,
"altitudeAccuracy": null
}
},
"start": {
"dateTime": "2018-04-30T13:00:00.0000000Z",
"timeZone": "UTC"
},
"end": {
"dateTime": "2018-04-30T13:30:00.0000000Z",
"timeZone": "UTC"
},
"serviceLocation": {
"displayName": "Customer location (987 Third Avenue, Buffalo, NY 98052, USA)",
"locationEmailAddress": null,
"locationUri": "",
"locationType": null,
"uniqueId": null,
"uniqueIdType": null,
"address": {
"type": "home",
"postOfficeBox": "",
"street": "",
"city": "",
"state": "",
"countryOrRegion": "",
"postalCode": ""
},
"coordinates": {
"altitude": null,
"latitude": null,
"longitude": null,
"accuracy": null,
"altitudeAccuracy": null
}
},
"reminders": [],
"invoiceDate": {
"dateTime": "2018-04-30T13:30:00.0000000Z",
"timeZone": "UTC"
}
},
{
"id": "AAMkADKnAAA=",
"selfServiceAppointmentId": "00000000-0000-0000-0000-000000000000",
"customerId": "7ed53fa5-9ef2-4f2f-975b-27447440bc09",
"customerName": "Jordan Miller",
"customerEmailAddress": "jordanm#contoso.com",
"customerPhone": "213-555-0199",
"customerNotes": null,
"serviceId": "57da6774-a087-4d69-b0e6-6fb82c339976",
"serviceName": "Catered bento",
"duration": "PT30M",
"preBuffer": "PT5M",
"postBuffer": "PT10M",
"priceType": "fixedPrice",
"price": 10,
"serviceNotes": null,
"optOutOfCustomerEmail": false,
"staffMemberIds": [],
"invoiceAmount": 10,
"invoiceId": "1001",
"invoiceStatus": "open",
"invoiceUrl": "theInvoiceUrl",
"customerLocation": {
"displayName": "Customer",
"locationEmailAddress": null,
"locationUri": "",
"locationType": null,
"uniqueId": null,
"uniqueIdType": null,
"address": {
"type": "home",
"postOfficeBox": "",
"street": "",
"city": "",
"state": "",
"countryOrRegion": "",
"postalCode": ""
},
"coordinates": {
"altitude": null,
"latitude": null,
"longitude": null,
"accuracy": null,
"altitudeAccuracy": null
}
},
"start": {
"dateTime": "2018-05-01T12:00:00.0000000Z",
"timeZone": "UTC"
},
"end": {
"dateTime": "2018-05-01T12:30:00.0000000Z",
"timeZone": "UTC"
},
"serviceLocation": {
"displayName": "Customer location (123 First Avenue, Buffalo, NY 98052, USA)",
"locationEmailAddress": null,
"locationUri": "",
"locationType": null,
"uniqueId": null,
"uniqueIdType": null,
"address": {
"type": "home",
"postOfficeBox": "",
"street": "",
"city": "",
"state": "",
"countryOrRegion": "",
"postalCode": ""
},
"coordinates": {
"altitude": null,
"latitude": null,
"longitude": null,
"accuracy": null,
"altitudeAccuracy": null
}
},
"reminders": [],
"invoiceDate": {
"dateTime": "2018-05-01T12:30:00.0000000Z",
"timeZone": "UTC"
}
}
]
}
And this is what im getting for the start and end date time:
start:
dateTime: "0001-01-01T00:00:00.0000000Z"
timeZone: "Etc/UTC"
end:
dateTime: "0001-01-01T00:00:00.0000000Z"
timeZone: "Etc/UTC"
I dont know what i'm doing wrong, i'd appreciate any help.
So for some reason using this URL:
GET /bookingBusinesses/{id}/calendarView?start={start-value}&end={end-value}
did end up giving me the exact results i was looking with correct time and everything the list appointments url was giving me.
I guess that's why this is still in BETA
I'm trying to output all of the customer id's within my JSON data. I am using ejs as my templating engine. So far I'm only able to succsefully output 1 customer id via:
<p><%= jsonOrderData.orders[0].customer.id %></p>
When I try to loop through each order I get Cannot read property 'id' of undefined
for loop to loop through
<% for (var i = 0; i < jsonOrderData.orders.length; i++) {%>
<p>Customer: <%= jsonOrderData.orders[i].customer.id %></p>
<% }; %>
If I remove the .id after customer the error then goes away. It then outputs
Customer:[object Object] 50 times which is the legth of the json data.
I don't understand why it's not working within the loop when adding .id when it works fine without the loop manually setting the index?
JSON DATA (Cut Down 2 Orders)
{
"orders": [
{
"id": 533078016054,
"email": "email#gmail.com",
"closed_at": null,
"created_at": "2018-08-10T05:03:36+01:00",
"updated_at": "2018-08-10T05:03:37+01:00",
"number": 52,
"note": "",
"token": "f4877048c08eb98180ee5fda34f978bc",
"gateway": "manual",
"test": false,
"total_price": "13.98",
"subtotal_price": "13.98",
"total_weight": 0,
"total_tax": "0.00",
"taxes_included": false,
"currency": "GBP",
"financial_status": "pending",
"confirmed": true,
"total_discounts": "0.00",
"total_line_items_price": "13.98",
"cart_token": null,
"buyer_accepts_marketing": false,
"name": "#MW1052",
"referring_site": null,
"landing_site": null,
"cancelled_at": null,
"cancel_reason": null,
"total_price_usd": "18.00",
"checkout_token": null,
"reference": null,
"user_id": 1706983449,
"location_id": null,
"source_identifier": null,
"source_url": null,
"processed_at": "2018-08-10T05:03:36+01:00",
"device_id": null,
"phone": null,
"customer_locale": null,
"app_id": 1354745,
"browser_ip": null,
"landing_site_ref": null,
"order_number": 1052,
"discount_applications": [],
"discount_codes": [],
"note_attributes": [],
"payment_gateway_names": [
"manual"
],
"processing_method": "manual",
"checkout_id": null,
"source_name": "shopify_draft_order",
"fulfillment_status": null,
"tax_lines": [],
"tags": "",
"contact_email": "email#gmail.com",
"order_status_url": "https://checkout.shopify.com/1245839385/orders/f4877048c08eb98180ee5fda34f978bc/authenticate?key=redacted",
"admin_graphql_api_id": "gid://shopify/Order/redacted",
"line_items": [
{
"id": 1350736445494,
"variant_id": 8725905539126,
"title": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt",
"quantity": 1,
"price": "6.99",
"sku": "ss15",
"variant_title": "S / Bottle Green",
"vendor": "Fruit Of The Loom",
"fulfillment_service": "manual",
"product_id": 719146287158,
"requires_shipping": true,
"taxable": false,
"gift_card": false,
"name": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt - S / Bottle Green",
"variant_inventory_management": "shopify",
"properties": [],
"product_exists": true,
"fulfillable_quantity": 1,
"grams": 0,
"total_discount": "0.00",
"fulfillment_status": null,
"discount_allocations": [],
"admin_graphql_api_id": "gid://shopify/LineItem/1350736445494",
"tax_lines": [
{
"title": "VAT",
"price": "0.00",
"rate": 0.2
}
]
},
{
"id": 1350736478262,
"variant_id": 8725905440822,
"title": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt",
"quantity": 1,
"price": "6.99",
"sku": "ss12",
"variant_title": "S / Heather Grey",
"vendor": "Fruit Of The Loom",
"fulfillment_service": "manual",
"product_id": 719146287158,
"requires_shipping": true,
"taxable": false,
"gift_card": false,
"name": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt - S / Heather Grey",
"variant_inventory_management": "shopify",
"properties": [],
"product_exists": true,
"fulfillable_quantity": 1,
"grams": 0,
"total_discount": "0.00",
"fulfillment_status": null,
"discount_allocations": [],
"admin_graphql_api_id": "gid://shopify/LineItem/1350736478262",
"tax_lines": [
{
"title": "VAT",
"price": "0.00",
"rate": 0.2
}
]
}
],
"shipping_lines": [],
"billing_address": {
"first_name": "John",
"address1": "17A Oaklands Business Centre",
"phone": null,
"city": "Worthing",
"zip": "BN11 5LH",
"province": null,
"country": "United Kingdom",
"last_name": "Doe",
"address2": "Elm Grove",
"company": null,
"latitude": 50.8162744,
"longitude": -0.4010653,
"name": "Jogn Doe",
"country_code": "GB",
"province_code": null
},
"shipping_address": {
"first_name": "John",
"address1": "17A Oaklands Business Centre",
"phone": null,
"city": "Worthing",
"zip": "BN11 5LH",
"province": null,
"country": "United Kingdom",
"last_name": "Doe",
"address2": "Elm Grove",
"company": null,
"latitude": 50.8162744,
"longitude": -0.4010653,
"name": "John Doe",
"country_code": "GB",
"province_code": null
},
"fulfillments": [],
"refunds": [],
"customer": {
"id": 556974014518,
"email": "email#gmail.com",
"accepts_marketing": false,
"created_at": "2018-06-26T00:26:55+01:00",
"updated_at": "2018-08-10T05:03:36+01:00",
"first_name": "John",
"last_name": "Doe",
"orders_count": 22,
"state": "enabled",
"total_spent": "0.00",
"last_order_id": 533078016054,
"note": null,
"verified_email": true,
"multipass_identifier": null,
"tax_exempt": false,
"phone": null,
"tags": "",
"last_order_name": "#MW1052",
"admin_graphql_api_id": "gid://shopify/Customer/556974014518",
"default_address": {
"id": 601657278518,
"customer_id": 556974014518,
"first_name": "John",
"last_name": "Doe",
"company": null,
"address1": "17A Oaklands Business Centre",
"address2": "Elm Grove",
"city": "Worthing",
"province": null,
"country": "United Kingdom",
"zip": "BN11 5LH",
"phone": null,
"name": "John Doe",
"province_code": null,
"country_code": "GB",
"country_name": "United Kingdom",
"default": true
}
}
},
{
"id": 532977778742,
"email": "james#bungeedesign.com",
"closed_at": null,
"created_at": "2018-08-09T22:18:53+01:00",
"updated_at": "2018-08-09T22:18:53+01:00",
"number": 51,
"note": "",
"token": "a292d75bd7011cf255a1bf236b23d0a5",
"gateway": "manual",
"test": false,
"total_price": "6.99",
"subtotal_price": "6.99",
"total_weight": 0,
"total_tax": "0.00",
"taxes_included": false,
"currency": "GBP",
"financial_status": "pending",
"confirmed": true,
"total_discounts": "0.00",
"total_line_items_price": "6.99",
"cart_token": null,
"buyer_accepts_marketing": true,
"name": "#MW1051",
"referring_site": null,
"landing_site": null,
"cancelled_at": null,
"cancel_reason": null,
"total_price_usd": "9.00",
"checkout_token": null,
"reference": null,
"user_id": 1706983449,
"location_id": 1327759385,
"source_identifier": null,
"source_url": null,
"processed_at": "2018-08-09T22:18:53+01:00",
"device_id": null,
"phone": null,
"customer_locale": null,
"app_id": 1354745,
"browser_ip": null,
"landing_site_ref": null,
"order_number": 1051,
"discount_applications": [],
"discount_codes": [],
"note_attributes": [],
"payment_gateway_names": [
"manual"
],
"processing_method": "manual",
"checkout_id": null,
"source_name": "shopify_draft_order",
"fulfillment_status": null,
"tax_lines": [],
"tags": "",
"contact_email": "james#bungeedesign.com",
"order_status_url": "https://checkout.shopify.com/1245839385/orders/a292d75bd7011cf255a1bf236b23d0a5/authenticate?key=9322877ce6ce34be2feeb127d73d0f89",
"admin_graphql_api_id": "gid://shopify/Order/532977778742",
"line_items": [
{
"id": 1350552453174,
"variant_id": 8725905408054,
"title": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt",
"quantity": 1,
"price": "6.99",
"sku": "ss11",
"variant_title": "S / Black",
"vendor": "Fruit Of The Loom",
"fulfillment_service": "manual",
"product_id": 719146287158,
"requires_shipping": true,
"taxable": false,
"gift_card": false,
"name": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt - S / Black",
"variant_inventory_management": "shopify",
"properties": [],
"product_exists": true,
"fulfillable_quantity": 1,
"grams": 0,
"total_discount": "0.00",
"fulfillment_status": null,
"discount_allocations": [],
"admin_graphql_api_id": "gid://shopify/LineItem/1350552453174",
"tax_lines": [
{
"title": "VAT",
"price": "0.00",
"rate": 0.2
}
]
}
],
"shipping_lines": [],
"fulfillments": [],
"refunds": [],
"customer": {
"id": 552537620534,
"email": "james#bungeedesign.com",
"accepts_marketing": true,
"created_at": "2018-06-15T10:44:13+01:00",
"updated_at": "2018-08-09T22:18:53+01:00",
"first_name": "James",
"last_name": "Rogers",
"orders_count": 18,
"state": "enabled",
"total_spent": "0.00",
"last_order_id": 532977778742,
"note": null,
"verified_email": true,
"multipass_identifier": null,
"tax_exempt": false,
"phone": null,
"tags": "password page, prospect",
"last_order_name": "#MW1051",
"admin_graphql_api_id": "gid://shopify/Customer/552537620534"
}
}
]
}
What you have runs fine. It might be possible that something is getting lost in translation or .id is at another level. My guess is that you are not setting the variable jsonOrderData as you are expecting.
If you do console.log(jsonOrderData); do you get what you expect?
This works fine:
const json = {
"orders": [
{
"id": 533078016054,
"email": "email#gmail.com",
"closed_at": null,
"created_at": "2018-08-10T05:03:36+01:00",
"updated_at": "2018-08-10T05:03:37+01:00",
"number": 52,
"note": "",
"token": "f4877048c08eb98180ee5fda34f978bc",
"gateway": "manual",
"test": false,
"total_price": "13.98",
"subtotal_price": "13.98",
"total_weight": 0,
"total_tax": "0.00",
"taxes_included": false,
"currency": "GBP",
"financial_status": "pending",
"confirmed": true,
"total_discounts": "0.00",
"total_line_items_price": "13.98",
"cart_token": null,
"buyer_accepts_marketing": false,
"name": "#MW1052",
"referring_site": null,
"landing_site": null,
"cancelled_at": null,
"cancel_reason": null,
"total_price_usd": "18.00",
"checkout_token": null,
"reference": null,
"user_id": 1706983449,
"location_id": null,
"source_identifier": null,
"source_url": null,
"processed_at": "2018-08-10T05:03:36+01:00",
"device_id": null,
"phone": null,
"customer_locale": null,
"app_id": 1354745,
"browser_ip": null,
"landing_site_ref": null,
"order_number": 1052,
"discount_applications": [],
"discount_codes": [],
"note_attributes": [],
"payment_gateway_names": [
"manual"
],
"processing_method": "manual",
"checkout_id": null,
"source_name": "shopify_draft_order",
"fulfillment_status": null,
"tax_lines": [],
"tags": "",
"contact_email": "email#gmail.com",
"order_status_url": "https://checkout.shopify.com/1245839385/orders/f4877048c08eb98180ee5fda34f978bc/authenticate?key=redacted",
"admin_graphql_api_id": "gid://shopify/Order/redacted",
"line_items": [
{
"id": 1350736445494,
"variant_id": 8725905539126,
"title": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt",
"quantity": 1,
"price": "6.99",
"sku": "ss15",
"variant_title": "S / Bottle Green",
"vendor": "Fruit Of The Loom",
"fulfillment_service": "manual",
"product_id": 719146287158,
"requires_shipping": true,
"taxable": false,
"gift_card": false,
"name": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt - S / Bottle Green",
"variant_inventory_management": "shopify",
"properties": [],
"product_exists": true,
"fulfillable_quantity": 1,
"grams": 0,
"total_discount": "0.00",
"fulfillment_status": null,
"discount_allocations": [],
"admin_graphql_api_id": "gid://shopify/LineItem/1350736445494",
"tax_lines": [
{
"title": "VAT",
"price": "0.00",
"rate": 0.2
}
]
},
{
"id": 1350736478262,
"variant_id": 8725905440822,
"title": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt",
"quantity": 1,
"price": "6.99",
"sku": "ss12",
"variant_title": "S / Heather Grey",
"vendor": "Fruit Of The Loom",
"fulfillment_service": "manual",
"product_id": 719146287158,
"requires_shipping": true,
"taxable": false,
"gift_card": false,
"name": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt - S / Heather Grey",
"variant_inventory_management": "shopify",
"properties": [],
"product_exists": true,
"fulfillable_quantity": 1,
"grams": 0,
"total_discount": "0.00",
"fulfillment_status": null,
"discount_allocations": [],
"admin_graphql_api_id": "gid://shopify/LineItem/1350736478262",
"tax_lines": [
{
"title": "VAT",
"price": "0.00",
"rate": 0.2
}
]
}
],
"shipping_lines": [],
"billing_address": {
"first_name": "John",
"address1": "17A Oaklands Business Centre",
"phone": null,
"city": "Worthing",
"zip": "BN11 5LH",
"province": null,
"country": "United Kingdom",
"last_name": "Doe",
"address2": "Elm Grove",
"company": null,
"latitude": 50.8162744,
"longitude": -0.4010653,
"name": "Jogn Doe",
"country_code": "GB",
"province_code": null
},
"shipping_address": {
"first_name": "John",
"address1": "17A Oaklands Business Centre",
"phone": null,
"city": "Worthing",
"zip": "BN11 5LH",
"province": null,
"country": "United Kingdom",
"last_name": "Doe",
"address2": "Elm Grove",
"company": null,
"latitude": 50.8162744,
"longitude": -0.4010653,
"name": "John Doe",
"country_code": "GB",
"province_code": null
},
"fulfillments": [],
"refunds": [],
"customer": {
"id": 556974014518,
"email": "email#gmail.com",
"accepts_marketing": false,
"created_at": "2018-06-26T00:26:55+01:00",
"updated_at": "2018-08-10T05:03:36+01:00",
"first_name": "John",
"last_name": "Doe",
"orders_count": 22,
"state": "enabled",
"total_spent": "0.00",
"last_order_id": 533078016054,
"note": null,
"verified_email": true,
"multipass_identifier": null,
"tax_exempt": false,
"phone": null,
"tags": "",
"last_order_name": "#MW1052",
"admin_graphql_api_id": "gid://shopify/Customer/556974014518",
"default_address": {
"id": 601657278518,
"customer_id": 556974014518,
"first_name": "John",
"last_name": "Doe",
"company": null,
"address1": "17A Oaklands Business Centre",
"address2": "Elm Grove",
"city": "Worthing",
"province": null,
"country": "United Kingdom",
"zip": "BN11 5LH",
"phone": null,
"name": "John Doe",
"province_code": null,
"country_code": "GB",
"country_name": "United Kingdom",
"default": true
}
}
},
{
"id": 532977778742,
"email": "james#bungeedesign.com",
"closed_at": null,
"created_at": "2018-08-09T22:18:53+01:00",
"updated_at": "2018-08-09T22:18:53+01:00",
"number": 51,
"note": "",
"token": "a292d75bd7011cf255a1bf236b23d0a5",
"gateway": "manual",
"test": false,
"total_price": "6.99",
"subtotal_price": "6.99",
"total_weight": 0,
"total_tax": "0.00",
"taxes_included": false,
"currency": "GBP",
"financial_status": "pending",
"confirmed": true,
"total_discounts": "0.00",
"total_line_items_price": "6.99",
"cart_token": null,
"buyer_accepts_marketing": true,
"name": "#MW1051",
"referring_site": null,
"landing_site": null,
"cancelled_at": null,
"cancel_reason": null,
"total_price_usd": "9.00",
"checkout_token": null,
"reference": null,
"user_id": 1706983449,
"location_id": 1327759385,
"source_identifier": null,
"source_url": null,
"processed_at": "2018-08-09T22:18:53+01:00",
"device_id": null,
"phone": null,
"customer_locale": null,
"app_id": 1354745,
"browser_ip": null,
"landing_site_ref": null,
"order_number": 1051,
"discount_applications": [],
"discount_codes": [],
"note_attributes": [],
"payment_gateway_names": [
"manual"
],
"processing_method": "manual",
"checkout_id": null,
"source_name": "shopify_draft_order",
"fulfillment_status": null,
"tax_lines": [],
"tags": "",
"contact_email": "james#bungeedesign.com",
"order_status_url": "https://checkout.shopify.com/1245839385/orders/a292d75bd7011cf255a1bf236b23d0a5/authenticate?key=9322877ce6ce34be2feeb127d73d0f89",
"admin_graphql_api_id": "gid://shopify/Order/532977778742",
"line_items": [
{
"id": 1350552453174,
"variant_id": 8725905408054,
"title": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt",
"quantity": 1,
"price": "6.99",
"sku": "ss11",
"variant_title": "S / Black",
"vendor": "Fruit Of The Loom",
"fulfillment_service": "manual",
"product_id": 719146287158,
"requires_shipping": true,
"taxable": false,
"gift_card": false,
"name": "Fruit of the Loom Poly/Cotton Piqué Polo Shirt - S / Black",
"variant_inventory_management": "shopify",
"properties": [],
"product_exists": true,
"fulfillable_quantity": 1,
"grams": 0,
"total_discount": "0.00",
"fulfillment_status": null,
"discount_allocations": [],
"admin_graphql_api_id": "gid://shopify/LineItem/1350552453174",
"tax_lines": [
{
"title": "VAT",
"price": "0.00",
"rate": 0.2
}
]
}
],
"shipping_lines": [],
"fulfillments": [],
"refunds": [],
"customer": {
"id": 552537620534,
"email": "james#bungeedesign.com",
"accepts_marketing": true,
"created_at": "2018-06-15T10:44:13+01:00",
"updated_at": "2018-08-09T22:18:53+01:00",
"first_name": "James",
"last_name": "Rogers",
"orders_count": 18,
"state": "enabled",
"total_spent": "0.00",
"last_order_id": 532977778742,
"note": null,
"verified_email": true,
"multipass_identifier": null,
"tax_exempt": false,
"phone": null,
"tags": "password page, prospect",
"last_order_name": "#MW1051",
"admin_graphql_api_id": "gid://shopify/Customer/552537620534"
}
}
]
};
for (let i = 0; i < json.orders.length; i++) {
const order = json.orders[i];
console.log(order.customer.id);
}