Last active
March 8, 2024 14:18
-
-
Save MaximilianoRicoTabo/7b07c830a1cb68e60865df993fdbb9db to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* | |
* Custom function to add a late fee to the checkout page in Paid Memberships Pro | |
* | |
* link: TBD | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* | |
*/ | |
/** | |
* Custom function to add a late fee to the checkout page in Paid Memberships Pro | |
* | |
* @param object $level The level object being checked out for. | |
*/ | |
function my_pmpro_checkout_level( $level ) { | |
//get logged in user | |
$user = wp_get_current_user(); | |
//Bail if the user doesn't have the Lapsed Member role. | |
if( ! in_array( 'lapsed_member', (array) $user->roles ) ) { | |
return $level; | |
} | |
//check if level id is the level want to customize. Modify accordingly | |
if( $level->id == "3" ) { | |
//Get the today date without year | |
$today = date("m-d"); | |
//Check if the checkout is between 01-01 and 01-30 or 07-01 and 12-31 and apply late fee policies. $95, 95 + 10 or 45 + 10 respectively. Switch | |
if( $today >= "01-01" && $today <= "01-30") { | |
$level->billing_amount = 95; | |
} else if ( $today >= "01-30" && $today <= "06-30") { | |
$level->billing_amount = 105; | |
} else { | |
$level->billing_amount = 55; | |
} | |
} | |
return $level; | |
} | |
add_filter("pmpro_checkout_level", "my_pmpro_checkout_level"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment