I’m trying to get a list of all my subscriptions in Woocommerce. I have read about WC_Subscriptions_Manager::get_subscription(), but I don’t know how to use it. Please keep in mind that I have almost zero knowledge concerning PHP.
Someone asked a similar question on the forum. I finally used the following code:
<?php if(isset($_REQUEST['Action']))
{
$Action = $_REQUEST['Action'];
switch($Action)
{
case "ValidateSubscription":
include('../../wp-load.php'); //Guessing this path based on your code sample... should be wp root
$Subscriptions = WC_Subscriptions_Manager::get_all_users_subscriptions();
print_r($Subscriptions);
break;
default:
echo "invalid action";
}
}else
{
echo "no action specified";
}
?>
How can I use it?
Thanks for your help!
You can use wcs_get_users_subscriptions(). If you don’t pass a user_id argument, the default is to get the current user. The function returns all subscriptions.