PHP function to:
- Get current customer ID
- If customer has subscription proceed
- If EXISTS -> Get latest customer subscription renewal order
- Check status of renewal order (i.e. 'pending payment', 'on-hold', processing, 'complete')
- RETURN status of renewal order
Here's what I have so far:
function get_last_customer_renewal_order() {
$current_user_id = get_current_user_id();
if (has_woocommerce_subscription('','','')){
$subscriptions = wcs_get_users_subscriptions($current_user_id);
$related_order_ID = array();
$related_orders = array();
foreach($subscriptions as $subscription) {
// The subscription ID
$related_order_ID[] = $subscription->get_related_orders( 'ids', 'renewal' );
foreach($related_order_ID as $related_orders) {
foreach($related_orders as $related_order) {
$order = wc_get_order( print_r($related_order[0]));
echo $order->get_status;
}
}
}