Skip to content

Commit

Permalink
Add null verification to avoid GetClass on null
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Starosta committed Apr 24, 2019
1 parent 4301666 commit 6302470
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 6302470

Please sign in to comment.