Merge branch 'master' into package-details
This commit is contained in:
@@ -18,8 +18,19 @@ class Wiaas_Order {
|
||||
add_filter('woocommerce_rest_prepare_shop_order_object', array(__CLASS__, 'transform_rest_order'), 999, 3);
|
||||
|
||||
add_filter('woocommerce_rest_orders_prepare_object_query', array( __CLASS__, 'wiaas_prepare_rest_orders_query'), 10, 2);
|
||||
|
||||
add_filter('woocommerce_new_order_note_data', array( __CLASS__, 'update_new_order_comment_date'), 10, 3);
|
||||
}
|
||||
|
||||
public static function update_new_order_comment_date($comment_data, $order_data) {
|
||||
$user = wp_get_current_user();
|
||||
|
||||
$comment_data['comment_author'] = $user->display_name;
|
||||
$comment_data['comment_author_email'] = $user->user_email;
|
||||
|
||||
return $comment_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignees order to corresponding user organization when order is created.
|
||||
*
|
||||
@@ -94,6 +105,8 @@ class Wiaas_Order {
|
||||
$data = self::_append_commercial_lead_info($data, $order, $request);
|
||||
|
||||
$data = self::_append_wiaas_order_details($data, $order, $request);
|
||||
|
||||
$data = self::_append_order_comments($data, $order, $request);
|
||||
|
||||
$response->set_data($data);
|
||||
|
||||
@@ -126,6 +139,7 @@ class Wiaas_Order {
|
||||
private static function _append_commercial_lead_info($data, $order, $request) {
|
||||
|
||||
$data['commercial_lead'] = array(
|
||||
'id' => 1,
|
||||
'name' => 'Coor Service Management',
|
||||
'phone' => '123456789',
|
||||
'email' => 'rikard@co-ideation.com'
|
||||
@@ -248,6 +262,34 @@ class Wiaas_Order {
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** Append order comments if single order is requested
|
||||
* @param $data
|
||||
* @param $order
|
||||
* @param $request
|
||||
*/
|
||||
private static function _append_order_comments($data, $order, $request) {
|
||||
|
||||
if (isset($request['id'])) {
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
$comments = $order->get_customer_order_notes();
|
||||
|
||||
$data['comments'] = array();
|
||||
|
||||
foreach ($comments as $comment) {
|
||||
$data['comments'][] = array(
|
||||
'id' => $comment->comment_ID,
|
||||
'content' => $comment->comment_content,
|
||||
'username' => $comment->comment_author,
|
||||
'date' => $comment->comment_date,
|
||||
'is_owner' => $comment->comment_author === $current_user->display_name,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Wiaas_Order::init();
|
||||
|
||||
Reference in New Issue
Block a user