WC_Helper::get_product_subscription_state()
Get subscription state of a given product ID.
Метод класса: WC_Helper{}
Хуков нет.
Возвращает
Массив
. Array of state_name => (bool) state
Использование
$result = WC_Helper::get_product_subscription_state( $product_id );
- $product_id(int) (обязательный)
- The product id.
Список изменений
Код WC_Helper::get_product_subscription_state() WC Helper::get product subscription state WC 9.4.2
public static function get_product_subscription_state( $product_id ) { $product_subscriptions = wp_list_filter( self::get_installed_subscriptions(), array( 'product_id' => $product_id ) ); $subscription = ! empty( $product_subscriptions ) ? array_shift( $product_subscriptions ) : array(); return array( 'unregistered' => empty( $subscription ), 'expired' => ( isset( $subscription['expired'] ) && $subscription['expired'] ), 'expiring' => ( isset( $subscription['expiring'] ) && $subscription['expiring'] ), 'key' => $subscription['product_key'] ?? '', 'order_id' => $subscription['order_id'] ?? '', ); }