Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dparker1005/bacd333e262a4072fb182fef84a79ea1 to your computer and use it in GitHub Desktop.
Save dparker1005/bacd333e262a4072fb182fef84a79ea1 to your computer and use it in GitHub Desktop.
Round down initial payment price for users switching levels. Useful to make prorated prices look more friendly.
<?php
// Copy from below here...
/*
* Round down initial payment price for users switching levels.
* Useful to make prorated prices look more friendly.
*/
function my_pmpro_checkout_level_round_down_initial_payment( $level ) {
// We only want to round down prorations.
if ( ! pmpro_hasMembershipLevel() ) {
return $level;
}
// Round down to an integer.
$level->initial_payment = floor( $level->initial_payment );
// Round down to nearest 25.
$level->initial_payment -= $level->initial_payment % 25;
return $level;
}
add_action( 'pmpro_checkout_level', 'my_pmpro_checkout_level_round_down_initial_payment', 15, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment