Last active
April 25, 2019 18:55
-
-
Save apmwebdev/f7016715fa28efbdcda887d1b5fb5d2c to your computer and use it in GitHub Desktop.
WooCommerce Subscriptions - Delete cancelled subscription
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_subscription_status_updated' , 'delete_cancelled_subscription' , 10 , 3 ); | |
function delete_cancelled_subscription( $subscription, $new_status, $old_status) { | |
if ($new_status == 'pending-cancel' || $new_status == 'cancelled') { | |
$subscription_id = $subscription->get_id(); | |
wc_delete_shop_order_transients($subscription_id); | |
wp_delete_post($subscription_id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment