mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-17 06:42:55 +00:00
2.2.3
This commit is contained in:

committed by
Remco Tolsma

parent
a7af434d12
commit
0691aa36da
@@ -19,17 +19,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
* @return string containing the limit type
|
||||
*/
|
||||
function wcs_get_product_limitation( $product ) {
|
||||
if ( ! is_object( $product ) ) {
|
||||
|
||||
if ( ! is_object( $product ) || ! is_a( $product, 'WC_Product' ) ) {
|
||||
$product = wc_get_product( $product );
|
||||
}
|
||||
|
||||
if ( ! isset( $product->product_custom_fields['_subscription_limit'][0] ) ) {
|
||||
return 'no';
|
||||
} elseif ( 'yes' == $product->product_custom_fields['_subscription_limit'][0] ) { // backward compatibility
|
||||
return 'any';
|
||||
} else {
|
||||
return $product->product_custom_fields['_subscription_limit'][0];
|
||||
}
|
||||
return apply_filters( 'woocommerce_subscriptions_product_limitation', WC_Subscriptions_Product::get_meta_data( $product, 'subscription_limit', 0 ), $product );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,5 +38,5 @@ function wcs_is_product_limited_for_user( $product, $user_id = 0 ) {
|
||||
$product = wc_get_product( $product );
|
||||
}
|
||||
|
||||
return ( ( 'active' == wcs_get_product_limitation( $product ) && wcs_user_has_subscription( $user_id, $product->id, 'on-hold' ) ) || ( 'no' !== wcs_get_product_limitation( $product ) && wcs_user_has_subscription( $user_id, $product->id, wcs_get_product_limitation( $product ) ) ) ) ? true : false;
|
||||
return ( ( 'active' == wcs_get_product_limitation( $product ) && wcs_user_has_subscription( $user_id, $product->get_id(), 'on-hold' ) ) || ( 'no' !== wcs_get_product_limitation( $product ) && wcs_user_has_subscription( $user_id, $product->get_id(), wcs_get_product_limitation( $product ) ) ) ) ? true : false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user