/**
  * Cancel subscriptions with PayPal Standard after the order has been successfully switched.
  *
  * @param int $order_id
  * @param string $old_status
  * @param string $new_status
  * @since 2.0.15
  */
 public static function maybe_cancel_paypal_after_switch($order_id, $old_status, $new_status)
 {
     $order_completed = in_array($new_status, array(apply_filters('woocommerce_payment_complete_order_status', 'processing', $order_id), 'processing', 'completed')) && in_array($old_status, apply_filters('woocommerce_valid_order_statuses_for_payment', array('pending', 'on-hold', 'failed')));
     if ($order_completed && wcs_order_contains_switch($order_id) && 'paypal_standard' == get_post_meta($order_id, '_old_payment_method', true)) {
         $old_profile_id = get_post_meta($order_id, '_old_paypal_subscription_id', true);
         if (!empty($old_profile_id)) {
             $subscriptions = wcs_get_subscriptions_for_order($order_id, array('order_type' => 'switch'));
             foreach ($subscriptions as $subscription) {
                 if (!wcs_is_paypal_profile_a($old_profile_id, 'billing_agreement')) {
                     $new_payment_method = $subscription->payment_method;
                     $new_profile_id = get_post_meta($subscription->id, '_paypal_subscription_id', true);
                     // grab the current paypal subscription id in case it's a billing agreement
                     update_post_meta($subscription->id, '_payment_method', 'paypal');
                     update_post_meta($subscription->id, '_paypal_subscription_id', $old_profile_id);
                     WCS_PayPal_Status_Manager::suspend_subscription($subscription);
                     // restore payment meta to the new data
                     update_post_meta($subscription->id, '_payment_method', $new_payment_method);
                     update_post_meta($subscription->id, '_paypal_subscription_id', $new_profile_id);
                 }
             }
         }
     }
 }
 /**
  * When a store manager or user suspends a subscription in the store, also suspend the subscription with PayPal.
  *
  * @since 1.1
  */
 public static function suspend_subscription_with_paypal($order, $product_id)
 {
     _deprecated_function(__METHOD__, '2.0', 'WCS_PayPal_Status_Manager::suspend_subscription( $subscription )');
     foreach (wcs_get_subscriptions_for_order($order, array('order_type' => 'parent')) as $subscription) {
         WCS_PayPal_Status_Manager::suspend_subscription($subscription);
     }
 }