/**
  * Check whether the cart needs payment even if the order total is $0 because it's a subscription switch request for a subscription using
  * PayPal Standard as the subscription.
  *
  * @param bool $needs_payment The existing flag for whether the cart needs payment or not.
  * @param WC_Cart $cart The WooCommerce cart object.
  * @return bool
  */
 public static function cart_needs_payment($needs_payment, $cart)
 {
     $cart_switch_items = WC_Subscriptions_Switcher::cart_contains_switches();
     if (false === $needs_payment && 0 == $cart->total && false !== $cart_switch_items && !empty($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-process_checkout') && isset($_POST['payment_method']) && 'paypal' == $_POST['payment_method'] && 'yes' !== get_option(WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no')) {
         foreach ($cart_switch_items as $cart_switch_details) {
             $subscription = wcs_get_subscription($cart_switch_details['subscription_id']);
             if ('paypal' === $subscription->payment_method && !wcs_is_paypal_profile_a(wcs_get_paypal_id($subscription->id), 'billing_agreement')) {
                 $needs_payment = true;
                 break;
             }
         }
     }
     return $needs_payment;
 }
 /**
  * Do not allow subscriptions to be switched using PayPal Standard as the payment method
  *
  * @since 2.0.16
  */
 public static function get_available_payment_gateways($available_gateways)
 {
     if (WC_Subscriptions_Switcher::cart_contains_switches() || isset($_GET['order_id']) && wcs_order_contains_switch($_GET['order_id'])) {
         foreach ($available_gateways as $gateway_id => $gateway) {
             if ('paypal' == $gateway_id && false == WCS_PayPal::are_reference_transactions_enabled()) {
                 unset($available_gateways[$gateway_id]);
             }
         }
     }
     return $available_gateways;
 }
 /**
  * Check whether the cart needs payment even if the order total is $0
  *
  * @param bool $needs_payment The existing flag for whether the cart needs payment or not.
  * @param WC_Cart $cart The WooCommerce cart object.
  * @return bool
  */
 public static function cart_needs_payment($needs_payment, $cart)
 {
     if (false === $needs_payment && self::cart_contains_subscription() && $cart->total == 0 && false === WC_Subscriptions_Switcher::cart_contains_switches() && 'yes' !== get_option(WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no')) {
         $recurring_total = 0;
         $is_one_period = true;
         $is_synced = false;
         foreach (WC()->cart->recurring_carts as $cart) {
             $recurring_total += $cart->total;
             $cart_length = wcs_cart_pluck($cart, 'subscription_length');
             if (0 == $cart_length || wcs_cart_pluck($cart, 'subscription_period_interval') != $cart_length) {
                 $is_one_period = false;
             }
             $is_synced = $is_synced || false != WC_Subscriptions_Synchroniser::cart_contains_synced_subscription($cart) ? true : false;
         }
         $has_trial = self::cart_contains_free_trial();
         if ($recurring_total > 0 && (false === $is_one_period || true === $has_trial || false !== $is_synced && false == WC_Subscriptions_Synchroniser::is_today(WC_Subscriptions_Synchroniser::calculate_first_payment_date($is_synced['data'], 'timestamp')))) {
             $needs_payment = true;
         }
     }
     return $needs_payment;
 }