Created
February 24, 2021 11:48
-
-
Save stuartduff/6cbe5599280f1e2376a98209f257d287 to your computer and use it in GitHub Desktop.
Remove resubscribe button for WC Subscriptions
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
/** | |
* 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