Created
January 6, 2020 21:49
-
-
Save NickGreen/253824ea475388ef18dfae2ae0e462a1 to your computer and use it in GitHub Desktop.
Remove 'cancel' button for gifted subscriptions only.
This file contains hidden or 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
<?php | |
function remove_cancel_gifted_subs( $actions, $subscription ) { | |
if ( WCS_Gifting::is_gifted_subscription( $subscription ) ) { | |
foreach ( $actions as $action_key => $action ) { | |
switch ( $action_key ) { | |
case 'cancel': // Hide "Cancel" button on subscriptions that are "active" or "on-hold"? | |
unset( $actions[ $action_key ] ); | |
break; | |
default: | |
error_log( '-- $action = ' . print_r( $action, true ) ); | |
break; | |
} | |
} | |
} | |
return $actions; | |
} | |
add_filter( 'wcs_view_subscription_actions', 'remove_cancel_gifted_subs', 100, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment