Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrick1229/12ded626944f1f8a8f6bb816efadb671 to your computer and use it in GitHub Desktop.
Save jrick1229/12ded626944f1f8a8f6bb816efadb671 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