Skip to content

Commit

Permalink
Merge pull request #768 from ebanx/upkeep/avoid-get-class-on-null
Browse files Browse the repository at this point in the history
Add null verification to avoid GetClass on null
  • Loading branch information
André Starosta authored Apr 25, 2019
2 parents 2cae7da + 6302470 commit 43f784b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions services/class-wc-ebanx-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,26 @@ public static function array_to_object( $array ) {
* @return bool
*/
public static function checkout_contains_subscription() {
global $product;
if ( class_exists( 'WC_Subscription' ) ) {
return WC_Subscriptions_Cart::cart_contains_subscription() || strpos( get_class( $product ), 'Subscription' ) !== false;
return WC_Subscriptions_Cart::cart_contains_subscription() || self::product_contains_subscription();
}

return false;
}

/**
*
*
* @return boolean
*/
private static function product_contains_subscription() {
global $product;
if ( is_null( $product ) ) {
return false;
}
return strpos( get_class( $product ), 'Subscription' ) !== false;
}

/**
*
* @param string $country_abbr
Expand Down

0 comments on commit 43f784b

Please sign in to comment.