Use order notes for comments
This commit is contained in:
@@ -9,13 +9,6 @@ function formatAddress(addressObject) {
|
||||
return `${addressObject.address_1}, ${addressObject.city}, ${addressObject.country}, ${addressObject.postcode}`;
|
||||
}
|
||||
|
||||
function extractComments(metaDataArray){
|
||||
const commentsObject = metaDataArray.find(metaDataElement => {
|
||||
return metaDataElement.key === "comments";
|
||||
});
|
||||
return commentsObject ? JSON.parse(commentsObject.value) : [];
|
||||
}
|
||||
|
||||
export const fromWCOrder = (WCOrder) => {
|
||||
let processInfo = Object.assign({},WCOrder['delivery-process']);
|
||||
if (WCOrder['delivery-process']){
|
||||
@@ -59,7 +52,13 @@ export const fromWCOrder = (WCOrder) => {
|
||||
};
|
||||
}),
|
||||
process: processInfo,
|
||||
comments: extractComments(WCOrder.meta_data),
|
||||
comments: WCOrder.comments ? WCOrder.comments.map(comment => ({
|
||||
id: comment.id,
|
||||
comment: comment.content,
|
||||
username: comment.username,
|
||||
dateCreated: formatDate(comment.date),
|
||||
isOwner: comment['is_owner']
|
||||
})) : [],
|
||||
deliveryAddress: formatAddress(WCOrder.shipping),
|
||||
customer: WCOrder.customer,
|
||||
commercialLead: WCOrder['commercial_lead']
|
||||
|
||||
Reference in New Issue
Block a user