/**
  * Checks if the current request is by a user to change the status of their subscription, and if it is
  * validate the subscription cancellation request and maybe processes the cancellation.
  *
  * @since 1.0
  * @deprecated 2.0
  */
 public static function maybe_change_users_subscription()
 {
     _deprecated_function(__METHOD__, '2.0', 'WCS_User_Change_Status_Handler::maybe_change_users_subscription()');
     WCS_User_Change_Status_Handler::maybe_change_users_subscription();
 }
        if ($changed) {
            do_action('woocommerce_customer_changed_subscription_to_' . $new_status, $subscription);
        }
    }
    /**
     * Checks if the user's current request to change the status of their subscription is valid.
     *
     * @since 2.0
     */
    public static function validate_request($user_id, $subscription, $new_status, $wpnonce = '')
    {
        $subscription = !is_object($subscription) ? wcs_get_subscription($subscription) : $subscription;
        if (!wcs_is_subscription($subscription)) {
            WC_Subscriptions::add_notice(__('That subscription does not exist. Please contact us if you need assistance.', 'woocommerce-subscriptions'), 'error');
            return false;
        } elseif (!empty($wpnonce) && wp_verify_nonce($wpnonce, $subscription->id . $subscription->get_status()) === false) {
            WC_Subscriptions::add_notice(__('Security error. Please contact us if you need assistance.', 'woocommerce-subscriptions'), 'error');
            return false;
        } elseif (!user_can($user_id, 'edit_shop_subscription_status', $subscription->id)) {
            WC_Subscriptions::add_notice(__('That doesn\'t appear to be one of your subscriptions.', 'woocommerce-subscriptions'), 'error');
            return false;
        } elseif (!$subscription->can_be_updated_to($new_status)) {
            // translators: placeholder is subscription's new status, translated
            WC_Subscriptions::add_notice(sprintf(__('That subscription can not be changed to %s. Please contact us if you need assistance.', 'woocommerce-subscriptions'), wcs_get_subscription_status_name($new_status)), 'error');
            return false;
        }
        return true;
    }
}
WCS_User_Change_Status_Handler::init();