Skip to content

Instantly share code, notes, and snippets.

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 hansschuijff/890ff73bcc65fc283a4a9478392a84e0 to your computer and use it in GitHub Desktop.
Save hansschuijff/890ff73bcc65fc283a4a9478392a84e0 to your computer and use it in GitHub Desktop.
Remove any given button from the My Subscriptions table on the My Account page. By default, only the "Change Payment Method" button is removed, but you can uncomment additional actions to remove those buttons also.
<?php
/**
* Plugin Name: Remove Subscription Action Buttons from My Account
* Plugin URI: https://gist.github.com/thenbrent/8851287/
* Description: Remove any given button from the <a href="http://docs.woothemes.com/document/subscriptions/customers-view/#section-2">My Subscriptions</a> table on the My Account page. By default, only the "Change Payment Method" button is removed, but you can uncomment additional actions to remove those buttons also.
* Author: Brent Shepherd
* Author URI:
* Version: 2.0
*/
/**
* 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 'change_payment_method': // Hide "Change Payment Method" button?
// case 'change_address': // Hide "Change Address" button?
// case 'switch': // Hide "Switch Subscription" button?
// case 'resubscribe': // Hide "Resubscribe" button from an expired or cancelled subscription?
// case 'pay': // Hide "Pay" button on subscriptions that are "on-hold" as they require payment?
// case 'reactivate': // Hide "Reactive" button on subscriptions that are "on-hold"?
// 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', '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