Use order notes for comments
This commit is contained in:
@@ -62,27 +62,16 @@ const sendComment = () => ({
|
||||
type: SEND_ORDER_COMMENT
|
||||
})
|
||||
|
||||
export const addComment = (idOrder, newComment, existingComments) => {
|
||||
export const addComment = (idOrder, newComment) => {
|
||||
return dispatch => {
|
||||
dispatch(sendComment());
|
||||
//TODO: get real user name and store in comment object
|
||||
const newCommentObject = {
|
||||
comment : newComment,
|
||||
date : moment().format("Do MMM, YY"),
|
||||
username: localStorage.getItem('username') || '-',
|
||||
}
|
||||
const concatenatedComments = (existingComments) ? existingComments.concat(newCommentObject) : [newCommentObject];
|
||||
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders/${idOrder}`,
|
||||
method: 'put',
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders/${idOrder}/notes`,
|
||||
method: 'post',
|
||||
data: {
|
||||
meta_data: [
|
||||
{
|
||||
key:'comments',
|
||||
value: JSON.stringify(concatenatedComments),
|
||||
}
|
||||
]
|
||||
note : newComment || 'Test comment',
|
||||
customer_note: true,
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
Reference in New Issue
Block a user