Forked from dparker1005/my_pmpro_add_account_creation_fee.php
Last active
September 22, 2020 15:53
-
-
Save ronalfy/aa8ed2f8a4498bcd210ef7d235cdd3e6 to your computer and use it in GitHub Desktop.
Charge Processing Fee to Certain Levels
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 | |
/** | |
* 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