Skip to content

Instantly share code, notes, and snippets.

@thenbrent
Last active July 21, 2024 13:59
Show Gist options
  • Save thenbrent/8851287 to your computer and use it in GitHub Desktop.
Save thenbrent/8851287 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 );
@CentralCrypto
Copy link

Guys, I hope you can help here....
I Cannot make the "Switch Suscription" appear. I'm using the Elementor plugin to create a custom "my account" page.
Here is my config:

Allow Switching |
X Between Subscription Variations 
X Between Grouped Subscriptions 
X Between Subscription Plans 
X Between Subscription Plans
-- | --
Prorate Recurring Payment: For Upgrades of Virtual Subscription Products Only 
Prorate Sign up Fee: Never (do not charge a sign up fee)  Prorate Subscription Length: For Virtual Subscription Products Only 
Switch Button Text: Upgrade&Downgrade
Allow Switching After: 0 day(s) from the subscription start date
Allow Switching After Each Renewal: 1 day(s) from the subscription renewal date
Prevent Switching: 0 day(s) before the subscription renewal date

The Subscriptions in fact are Products with Product Data = "Simple Subscrition" and "Virtual" field flagged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment