mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/78576819/hide-cancel-woocommerce-subscription-button-on-user-dashboard/78576972
14 lines
572 B
Text
14 lines
572 B
Text
add_filter('wcs_view_subscription_actions', 'delay_user_action_cancel_button', 10, 3 );
|
|
|
|
function delay_user_action_cancel_button( $actions, $subscription, $user_id ) {
|
|
// Check that 'cancel' action button is active
|
|
if ( ! isset($actions['cancel']) ) return $actions;
|
|
|
|
$start_date = $subscription->get_date('start'); // Get the start date
|
|
$days_period = 15; // Here define the "designated time limit" in days
|
|
|
|
if ( strtotime($start_date) + ( $days_period * DAY_IN_SECONDS ) >= time() ) {
|
|
unset($actions['cancel']);
|
|
}
|
|
return $actions;
|
|
}
|