/**
  * Init the mailer and call the notifications for subscription switch orders.
  *
  * @param int $user_id The ID of the user who the subscription belongs to
  * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
  * @return void
  */
 public static function send_switch_order_email($order_id)
 {
     WC()->mailer();
     if (wcs_order_contains_switch($order_id)) {
         do_action(current_filter() . '_switch_notification', $order_id);
     }
 }
 /**
  * Check if a given order was created to switch a subscription.
  *
  * @param WC_Order $order An order to check.
  * @return bool Returns true if the order switched a subscription, otherwise, false.
  * @since 1.4
  */
 public static function order_contains_subscription_switch($order_id)
 {
     _deprecated_function(__METHOD__, '2.0', 'wcs_order_contains_switch( $order_id )');
     return wcs_order_contains_switch($order_id);
 }
 /**
  * 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;
 }
/**
 * Checks an order to see if it contains a subscription.
 *
 * @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
 * @param array|string $order_type Can include 'parent', 'renewal', 'resubscribe' and/or 'switch'. Defaults to 'parent'.
 * @return bool True if the order contains a subscription that belongs to any of the given order types, otherwise false.
 * @since 2.0
 */
function wcs_order_contains_subscription($order, $order_type = array('parent', 'resubscribe', 'switch'))
{
    // Accept either an array or string (to make it more convenient for singular types, like 'parent' or 'any')
    if (!is_array($order_type)) {
        $order_type = array($order_type);
    }
    if (!is_object($order)) {
        $order = new WC_Order($order);
    }
    $contains_subscription = false;
    $get_all = in_array('any', $order_type) ? true : false;
    if ((in_array('parent', $order_type) || $get_all) && count(wcs_get_subscriptions_for_order($order->id, array('order_type' => 'parent'))) > 0) {
        $contains_subscription = true;
    } elseif ((in_array('renewal', $order_type) || $get_all) && wcs_order_contains_renewal($order)) {
        $contains_subscription = true;
    } elseif ((in_array('resubscribe', $order_type) || $get_all) && wcs_order_contains_resubscribe($order)) {
        $contains_subscription = true;
    } elseif ((in_array('switch', $order_type) || $get_all) && wcs_order_contains_switch($order)) {
        $contains_subscription = true;
    }
    return $contains_subscription;
}