WooCommerce Subscriptions - Check if a product is a subscription product

感情迁移 提交于 2019-12-19 10:23:41

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/41979866/woocommerce-subscriptions-check-if-a-product-is-a-subscription-product

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!