Filter linked organizations as customer
This commit is contained in:
@@ -18,10 +18,13 @@ class Wiaas_Admin_Organization {
|
||||
add_filter('woocommerce_customer_meta_fields', array(__CLASS__, 'hide_woocommerce_customer_fields'));
|
||||
|
||||
// save related customers when organization form data has been saved by acf
|
||||
add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 1);
|
||||
add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 11);
|
||||
|
||||
// load related customers for organization form
|
||||
add_filter('acf/load_value/name=_wiaas_organization_customers', array(__CLASS__, 'load_related_customer_organizations'), 10, 3);
|
||||
|
||||
// retrieve only customer organizations as options to link to commercial lead
|
||||
add_filter('acf/fields/taxonomy/query/name=_wiaas_organization_customers', array(__CLASS__, 'filter_customer_organizations'));
|
||||
}
|
||||
|
||||
public static function hide_woocommerce_customer_fields() {
|
||||
@@ -32,6 +35,22 @@ class Wiaas_Admin_Organization {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve only customer organization as options to link customers to commercial lead
|
||||
*
|
||||
* @param $args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function filter_customer_organizations($args) {
|
||||
|
||||
$args['meta_key'] = '_wiaas_organization_roles';
|
||||
$args['meta_value'] = 'customer';
|
||||
$args['meta_compare'] = 'LIKE';
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves related customers if organization new/edit form has been submited
|
||||
* Customer ids are collected from posted data of linked customers acf field and saved
|
||||
|
||||
Reference in New Issue
Block a user