Skip to content

Instantly share code, notes, and snippets.

@bryceadams
Created June 24, 2017 02:55
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 bryceadams/8ca7ad7936d215ba0d92b66ac3301d50 to your computer and use it in GitHub Desktop.
Save bryceadams/8ca7ad7936d215ba0d92b66ac3301d50 to your computer and use it in GitHub Desktop.
Automatically change 'pending cancel' subscriptions to 'cancelled'
<?php
/**
* Move pending cancellation to cancelled automatically.
*/
function metorik_custom_cancel_function( $subscription, $new_status, $old_status ) {
if ( 'pending-cancel' === $new_status ) {
$subscription->update_status( 'cancelled' );
}
}
add_action( 'woocommerce_subscription_status_updated', 'metorik_custom_cancel_function', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment