Reputation: 836
I'm getting crazy on this.
I'm making a wordpress plugin and I need to use wcs_user_has_subscription on every user to get the list of every user having this subscription.
Seem's pretty simple, but I can't make the function work when I give a specific user_id.
Everything work fine when I call the function like this :
$has_sub = wcs_user_has_subscription('', 4743, 'active');
but when I do something like this :
$subscribers = get_users('role=subscriber');
foreach ( $subscribers as $user ) {
$has_sub = wcs_user_has_subscription($user->id, 4743, 'active');
}
I get this error :
PHP Fatal error: Call to a member function get_order() on null in /path/to/woocommerce-subscriptions/wcs-functions.php on line 81
Am I missing something obvious ?
Upvotes: 1
Views: 3664
Reputation: 2210
You plugin loads get_order() even the woocommerce librairies aren't already load.
Upvotes: 1