2

I'd like to know how to determine if a given WC_Product object $product is a subscription product or not.

DaveFX
  • 407
  • 1
  • 8
  • 16

1 Answers1

21

You can use their helper function which is probably the most complete:

if( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $product ) ) {
    return TRUE;
} else {
    return FALSE;
}

Or you could also use WooCommerce's $product->is_type( $type ) check.

helgatheviking
  • 25,596
  • 11
  • 95
  • 152