WooCommerce 订阅 - 检查产品是否为订阅产品 [英] WooCommerce Subscriptions - Check if a product is a subscription product
本文介绍了WooCommerce 订阅 - 检查产品是否为订阅产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何确定给定的 WC_Product 对象 $product 是否为订阅产品.
I'd like to know how to determine if a given WC_Product object $product is a subscription product or not.
推荐答案
你可以使用他们的辅助函数,这可能是最完整的:
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;
}
或者您也可以使用 WooCommerce 的 $product->is_type( $type )
检查.
Or you could also use WooCommerce's $product->is_type( $type )
check.
这篇关于WooCommerce 订阅 - 检查产品是否为订阅产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文