Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ronalfy/aa8ed2f8a4498bcd210ef7d235cdd3e6 to your computer and use it in GitHub Desktop.
Save ronalfy/aa8ed2f8a4498bcd210ef7d235cdd3e6 to your computer and use it in GitHub Desktop.
Charge Processing Fee to Certain Levels
<?php
/**
* If user checkouts in certain levels, add a processing fee.
*
* 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/
*/
function my_pmpro_add_account_creation_fee( $checkout_level ) {
if ( ! function_exists( 'pmpro_getMembershipLevelsForUser' ) ) {
return $checkout_level;
}
// Skip users with no existing level, i.e., new users.
$maybe_level = pmpro_getMembershipLevelsForUser();
if ( ! $maybe_level ) {
return $checkout_level;
}
if ( 3 == $checkout_level->id || 12 == $checkout_level->id ) {
$checkout_level->initial_payment += 2.50;
}
return $checkout_level;
}
add_filter( 'pmpro_checkout_level', 'my_pmpro_add_account_creation_fee' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment