Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPry/91bae3b7629e8f8ac841d9e640f1e3d6 to your computer and use it in GitHub Desktop.
Save JPry/91bae3b7629e8f8ac841d9e640f1e3d6 to your computer and use it in GitHub Desktop.
<?php
add_action( 'woocommerce_customer_changed_subscription_to_cancelled', 'customer_skip_pending_cancellation' );
/**
* Change 'pending-cancel' status directly to 'cancelled'.
*
* @param WC_Subscription $subscription
*/
function customer_skip_pending_cancellation( $subscription ) {
if ( 'pending-cancel' === $subscription->get_status() ) {
$subscription->update_status( 'cancelled', 'Your subscription has been cancelled.' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment