Skip to content

Instantly share code, notes, and snippets.

@MaximilianoRicoTabo
Created March 4, 2024 14:07
Show Gist options
  • Save MaximilianoRicoTabo/4d642e80ef89942b271c3e0668cf8278 to your computer and use it in GitHub Desktop.
Save MaximilianoRicoTabo/4d642e80ef89942b271c3e0668cf8278 to your computer and use it in GitHub Desktop.
Customize level cost description depending on the date.
<?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/
*
*/
//Customize level text cost at checkout
function my_pmpro_level_cost_text($cost, $level) {
//check if level id is 3
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") {
$cost = "95";
} else if ( $today >= "01-30" && $today <= "06-30") {
$cost = "95 plus 10 late fee";
} else {
$cost = "95 minus 40 cause is very late";
}
}
return $cost;
}
add_filter("pmpro_level_cost_text", "my_pmpro_level_cost_text", 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment