Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrick1229/c5b32eb3681248bfc3af7bfcee72bbbf to your computer and use it in GitHub Desktop.
Save jrick1229/c5b32eb3681248bfc3af7bfcee72bbbf to your computer and use it in GitHub Desktop.
Add a 'Renew Now' button to the Subscriptions page in the My Account area
<?php
function wcs_add_renew_now_button_to_subscriptions_page($subscription) {
$actions = wcs_get_all_user_actions_for_subscription( $subscription, get_current_user_id() );
if(!empty($actions)){
foreach ( $actions as $key => $action ){
if(strtolower($action['name']) == "renew now"){
$renewNowLink = esc_url( $action['url'] );
echo "<a href='$renewNowLink' class='button subscription_renewal_early'>".$action['name']."</a>";
}
}
}
}
add_action( 'woocommerce_my_subscriptions_actions', 'wcs_add_renew_now_button_to_subscriptions_page', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment