This commit is contained in:
Prospress Inc
2017-04-11 09:25:24 +02:00
committed by Remco Tolsma
parent a7af434d12
commit 0691aa36da
127 changed files with 49016 additions and 4656 deletions

View File

@@ -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;
}