line item properties value by javascript

Solved
Ram_A
Excursionist
41 3 10

Hi,

 

I have a javascript code that retrieves order data to Google Sheets.

 

It works fine except that the  "properties" output comes in one cell like this: 

{name=Date, value=7 February 2023}

 

How to get the value of  "properties"  without the name or the brackets?

 

I am not sure about the script, so I am open to any recommendations.

 

Thanks.

 

script:

 

const data = orders.reduce((acc, order) => {
  const lineItems = order["line_items"].map(item => {
    return [      
      item["id"],
      item["title"],
      item["quantity"],
      item["price"],
      item["properties"],  ## This one
      order["created_at"],
      order["total_price"],
      order["customer"],
  ];
  });
  return acc.concat(lineItems);
}, []);

 

 

 

 

 

Accepted Solution (1)
Ram_A
Excursionist
41 3 10

This is an accepted solution.

Thanks for your response, I've just figured it out.

For anyone looking for the same thing, here's what worked with me to retrieve  the custom property value:

 

item["properties"] ? item["properties"].map(property => property.value).join(", ") : "",

 

 

 

 







View solution in original post

Replies 2 (2)
pawankumar
Shopify Partner
375 36 64

I think, it is a javascript object and you have to manipulate it separately

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- Need a Shopify developer? Chat on WhatsApp +91-9467121281
- Coffee Tip: Buymeacoffee  | Email: thepkpawankumar@gmail.com


Best regards,
Pawan
Ram_A
Excursionist
41 3 10

This is an accepted solution.

Thanks for your response, I've just figured it out.

For anyone looking for the same thing, here's what worked with me to retrieve  the custom property value:

 

item["properties"] ? item["properties"].map(property => property.value).join(", ") : "",