From 4d13ee40bce09da8aec0a62b5f89b3de4488e236 Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Wed, 17 Oct 2018 14:02:35 +0200 Subject: [PATCH] Add descriptive comments --- .../class-wiaas-admin-cl-customers.php | 16 ++++- .../admin-cl/class-wiaas-admin-cl-orders.php | 60 +++++++++++++++---- .../class-wiaas-access-management.php | 31 ++++++++++ .../wiaas/includes/class-wiaas-order.php | 21 ------- 4 files changed, 95 insertions(+), 33 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-customers.php b/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-customers.php index 106edc2..7d0addb 100644 --- a/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-customers.php +++ b/backend/app/plugins/wiaas/includes/admin/admin-cl/class-wiaas-admin-cl-customers.php @@ -1,6 +1,18 @@ get_meta('_wiaas_commercial_lead_id', true)); + if ($commercial_lead_id) { + Wiaas_User_Organization::assign_post_to_organization($order_id, $commercial_lead_id); + } + + } } Wiaas_Access_Management::init(); diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-order.php b/backend/app/plugins/wiaas/includes/class-wiaas-order.php index 20f1d44..e26189d 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-order.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-order.php @@ -21,8 +21,6 @@ class Wiaas_Order { add_filter('woocommerce_register_post_type_shop_order', array(__CLASS__, 'manage_order_settings')); - add_action('woocommerce_new_order', array( __CLASS__, 'assign_order_to_organization' )); - add_filter('woocommerce_rest_check_permissions', array( __CLASS__, 'check_order_access'), 10, 4); add_filter('woocommerce_rest_prepare_shop_order_object', array(__CLASS__, 'transform_rest_order'), 999, 3); @@ -70,25 +68,6 @@ class Wiaas_Order { return $comment_data; } - /** - * Assignees order to corresponding user organization when order is created. - * - * @param $order_id - */ - public static function assign_order_to_organization($order_id) { - // assign order to customer organization - $customer_id = wiaas_get_current_user_organization_id(); - Wiaas_User_Organization::assign_post_to_organization($order_id, $customer_id); - $order = wc_get_order($order_id); - - // assign order to commercial lead organization - $commercial_lead_id = absint($order->get_meta('_wiaas_commercial_lead_id', true)); - if ($commercial_lead_id) { - Wiaas_User_Organization::assign_post_to_organization($order_id, $commercial_lead_id); - } - - } - /** * Checks if current user has access to requested order/{orderId} via woocommerce REST API. * Endpoint `/orders` is filtered correctly by groups, but endpoint `/orders/{orderId}` will return order even if