Add descriptive comments
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Wiaas_Access_Management
|
||||
*/
|
||||
class Wiaas_Access_Management {
|
||||
|
||||
/**
|
||||
* Handles organization and role based access management to wiaas objects (orders, products)
|
||||
*
|
||||
* Using Groups Access for achieve this
|
||||
*
|
||||
*/
|
||||
|
||||
public static function init() {
|
||||
|
||||
add_action( 'save_post', array( __CLASS__, 'maybe_handle_product_access' ), 999, 2 );
|
||||
|
||||
add_action('woocommerce_new_order', array( __CLASS__, 'assign_order_to_organization' ));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,6 +56,25 @@ class Wiaas_Access_Management {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignees order to corresponding user organization when order is created.
|
||||
*
|
||||
* @param int $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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Wiaas_Access_Management::init();
|
||||
|
||||
Reference in New Issue
Block a user