Created
October 6, 2016 12:47
-
-
Save smeric/8754980acc4695df0882dfd5ca5b3a63 to your computer and use it in GitHub Desktop.
WooCommerce Memberships : allow renewal for active memberships even before membership expiration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allow membership renewal for active memberships | |
*/ | |
add_filter( 'wc_memberships_valid_membership_statuses_for_renewal', 'my_valid_membership_statuses_for_renewal' ); | |
function my_valid_membership_statuses_for_renewal( $statuses = array() ) { | |
$statuses[] = 'active'; | |
return $statuses; | |
} | |
/** | |
* Add the "Renew" button on memberships lists in members area for non-expired memberships | |
*/ | |
add_filter( "wc_memberships_members_area_my-memberships_actions", 'my_memberships_actions', 10, 3); | |
function my_memberships_actions( $default_actions, $user_membership, $object ) { | |
// Renew : Show not only for expired memberships | |
if ( ! $user_membership->is_expired() && $user_membership->get_plan()->has_products() ) { | |
$default_actions['renew'] = array( | |
'url' => $user_membership->get_renew_membership_url(), | |
'name' => __( 'Renew', 'woocommerce-memberships' ), | |
); | |
} | |
return $default_actions; | |
} |
Hi, I used same code however renewal link after make an order, Expire date is same even order is not sync with membership plan.
You have any idea there?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using your code and it is works well with 1 exception. Custom meta fields are not pre-populating. Is there anything in your code that would need to change to include custom fields?