WC_Helper::get_subscriptions() public WC 1.0
Get the connected user's subscriptions.
{} Это метод класса: WC_Helper{}
Хуков нет.
Возвращает
Массив.
Использование
$result = WC_Helper::get_subscriptions();
Код WC_Helper::get_subscriptions() WC Helper::get subscriptions WC 5.0.0
public static function get_subscriptions() {
$cache_key = '_woocommerce_helper_subscriptions';
$data = get_transient( $cache_key );
if ( false !== $data ) {
return $data;
}
// Obtain the connected user info.
$request = WC_Helper_API::get(
'subscriptions',
array(
'authenticated' => true,
)
);
if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
set_transient( $cache_key, array(), 15 * MINUTE_IN_SECONDS );
return array();
}
$data = json_decode( wp_remote_retrieve_body( $request ), true );
if ( empty( $data ) || ! is_array( $data ) ) {
$data = array();
}
set_transient( $cache_key, $data, 1 * HOUR_IN_SECONDS );
return $data;
}