Correct function to get the user’s latest Woocommerce Subscription?

use this code

$users_subscriptions = wcs_get_users_subscriptions($user_id);

retrieve the data using foreach

foreach ($users_subscriptions as $subscription){
  if ($subscription->has_status(array('active'))) {
         echo $subscription->get_id(); 
  }
}

There is some function to access subscription data. like
get_id(),get_date(‘end’) (to get last date of subscription ).

I hope its help you well.

Leave a Comment