Skip to content

Instantly share code, notes, and snippets.

@stuartduff
Created February 24, 2021 11:48
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 stuartduff/6cbe5599280f1e2376a98209f257d287 to your computer and use it in GitHub Desktop.
Save stuartduff/6cbe5599280f1e2376a98209f257d287 to your computer and use it in GitHub Desktop.
Remove resubscribe button for WC Subscriptions
/**
* Remove the "Change Payment Method" button from the My Subscriptions table.
*
* This isn't actually necessary because @see eg_subscription_payment_method_cannot_be_changed()
* will prevent the button being displayed, however, it is included here as an example of how to
* remove just the button but allow the change payment method process.
*/
function eg_remove_my_subscriptions_button( $actions, $subscription ) {
foreach ( $actions as $action_key => $action ) {
switch ( $action_key ) {
case 'resubscribe': // Hide "Resubscribe" button from an expired or cancelled subscription?
unset( $actions[ $action_key ] );
break;
default:
error_log( '-- $action = ' . print_r( $action, true ) );
break;
}
}
return $actions;
}
add_filter( 'wcs_view_subscription_actions', 'eg_remove_my_subscriptions_button', 100, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment