Skip to content

Instantly share code, notes, and snippets.

@NickGreen
Created January 6, 2020 21:49
Show Gist options
  • Save NickGreen/253824ea475388ef18dfae2ae0e462a1 to your computer and use it in GitHub Desktop.
Save NickGreen/253824ea475388ef18dfae2ae0e462a1 to your computer and use it in GitHub Desktop.
Remove 'cancel' button for gifted subscriptions only.
<?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