needs set to removal endpoint
This commit is contained in:
parent
9872622d8a
commit
1792f606e2
@ -407,6 +407,62 @@ function federated_needs_removal_subscriptions(){
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get needs set to removal
|
||||||
|
add_action('rest_api_init', 'federated_route_needs_set_to_removal_register');
|
||||||
|
|
||||||
|
function federated_route_needs_set_to_removal_register(){
|
||||||
|
//register routes here
|
||||||
|
register_rest_route(
|
||||||
|
'federated-rest/v1',
|
||||||
|
'needs-removal',
|
||||||
|
array(
|
||||||
|
'methods' => 'GET',
|
||||||
|
'callback' => 'federated_needs_set_to_removal_subscriptions',
|
||||||
|
'permissions_callback' => 'check_federated_permissions'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function federated_needs_set_to_removal_subscriptions(){
|
||||||
|
$cancelled_args = array(
|
||||||
|
'numberposts' => -1,
|
||||||
|
'post_type' => 'shop_subscription',
|
||||||
|
'post_status' => 'wc-cancelled',
|
||||||
|
'meta_key' => 'provision_status',
|
||||||
|
'meta_value' => 'provisioned'
|
||||||
|
);
|
||||||
|
|
||||||
|
$cancelled_posts = get_posts($cancelled_args);
|
||||||
|
|
||||||
|
$pending_args = array(
|
||||||
|
'numberposts' => -1,
|
||||||
|
'post_type' => 'shop_subscription',
|
||||||
|
'post_status' => 'wc-pending-cancel',
|
||||||
|
'meta_key' => 'provision_status',
|
||||||
|
'meta_value' => 'provisioned'
|
||||||
|
);
|
||||||
|
|
||||||
|
$pending_posts = get_posts($pending_args);
|
||||||
|
|
||||||
|
$posts = array_merge($cancelled_posts, $pending_posts);
|
||||||
|
|
||||||
|
$output = array();
|
||||||
|
|
||||||
|
foreach($posts as $post){
|
||||||
|
//Get data
|
||||||
|
$post_id = $post->ID;
|
||||||
|
$vm_id = get_field('vm_id', $post_id);
|
||||||
|
//Create object
|
||||||
|
$data = array();
|
||||||
|
$data['subscription_id'] = $post_id;
|
||||||
|
$data['vm_id'] = $vm_id;
|
||||||
|
//Add to output
|
||||||
|
array_push($output, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
//Get needs provision, get needs removal
|
//Get needs provision, get needs removal
|
||||||
add_action('rest_api_init', 'federated_route_needs_provision_register');
|
add_action('rest_api_init', 'federated_route_needs_provision_register');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user