Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Last active November 29, 2018 17:22
Show Gist options
  • Save jrick1229/928151c762848c8552b49aa09c67e753 to your computer and use it in GitHub Desktop.
Save jrick1229/928151c762848c8552b49aa09c67e753 to your computer and use it in GitHub Desktop.
<?php
function eg_remove_my_subscriptions_button( $actions, $subscription ) {
$product_id = 228; // Update with correct product ID
if ( $subscription->has_product( $product_id ) ) {
foreach ( $actions as $action_key => $action ) {
switch ( $action_key ) {
case 'change_payment_method': // Hide
// case 'change_address': // Hide
// case 'switch': // Hide
// case 'resubscribe': // Hide
// case 'pay': // Hide
// case 'reactivate': // Hide
// case 'cancel': // Hide
unset( $actions[ $action_key ] );
break;
default:
error_log( '-- $action = ' . print_r( $action, true ) );
break;
}
}
return $actions;
} else {
foreach ( $actions as $action_key => $action ) {
switch ( $action_key ) {
case 'change_payment_method': // Show
case 'change_address': // Show
case 'switch': // Show
case 'resubscribe': // Show
case 'pay': // Show
case 'reactivate': // Show
case 'cancel': // Show
// 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