Remove shop on org delete
This commit is contained in:
@@ -18,7 +18,7 @@ class Wiaas_Admin_Organization {
|
|||||||
add_filter('woocommerce_customer_meta_fields', array(__CLASS__, 'hide_woocommerce_customer_fields'));
|
add_filter('woocommerce_customer_meta_fields', array(__CLASS__, 'hide_woocommerce_customer_fields'));
|
||||||
|
|
||||||
// save related customers when organization form data has been saved by acf
|
// save related customers when organization form data has been saved by acf
|
||||||
add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 11);
|
// add_action('acf/save_post', array(__CLASS__, 'maybe_save_related_customers'), 11);
|
||||||
|
|
||||||
// load related customers for organization form
|
// load related customers for organization form
|
||||||
add_filter('acf/load_value/name=_wiaas_organization_customers', array(__CLASS__, 'load_related_customer_organizations'), 10, 3);
|
add_filter('acf/load_value/name=_wiaas_organization_customers', array(__CLASS__, 'load_related_customer_organizations'), 10, 3);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class Wiaas_Shop {
|
|||||||
// create new shop if organization was assigned commercial lead role
|
// create new shop if organization was assigned commercial lead role
|
||||||
// or remove shop if commercial lead role was removed for organization
|
// or remove shop if commercial lead role was removed for organization
|
||||||
add_action('wiaas_organization_roles_updated', array(__CLASS__, 'maybe_manage_shop_for_commercial_lead'), 10, 2);
|
add_action('wiaas_organization_roles_updated', array(__CLASS__, 'maybe_manage_shop_for_commercial_lead'), 10, 2);
|
||||||
|
|
||||||
|
add_action('wiaas_organization_deleted', array(__CLASS__, 'maybe_remove_shop'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_shop_customers($owner_id) {
|
public static function get_shop_customers($owner_id) {
|
||||||
@@ -100,6 +102,15 @@ class Wiaas_Shop {
|
|||||||
self::_maybe_remove_shop($owner_id);
|
self::_maybe_remove_shop($owner_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove shop
|
||||||
|
*
|
||||||
|
* @param int $owner_id
|
||||||
|
*/
|
||||||
|
public static function maybe_remove_shop($owner_id) {
|
||||||
|
self::_maybe_remove_shop($owner_id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register special prices taxonomy to enable search of packages by prices inside every shop
|
* Register special prices taxonomy to enable search of packages by prices inside every shop
|
||||||
*/
|
*/
|
||||||
@@ -197,6 +208,8 @@ class Wiaas_Shop {
|
|||||||
if ($attribute_id > 0) {
|
if ($attribute_id > 0) {
|
||||||
wc_delete_attribute($attribute_id);
|
wc_delete_attribute($attribute_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Wiaas_Shop_DB::remove_shop($owner_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -154,4 +154,15 @@ class Wiaas_Shop_DB {
|
|||||||
|
|
||||||
return $shops;
|
return $shops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function remove_shop($owner_id) {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$wpdb->query(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"DELETE FROM {$wpdb->prefix}wiaas_shop_customer_relationships
|
||||||
|
WHERE shop_owner_id = %d",
|
||||||
|
$owner_id )
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user