Created
June 20, 2022 09:30
-
-
Save ipokkel/c42c5a8a092e18556e64bb59976d5b8b to your computer and use it in GitHub Desktop.
Removes payment plans from a membership level checkout if a discount code is applied.
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 | |
/** | |
* This recipe removes payment plans from the PMPro checkout page if a | |
* discount code is applied. | |
* | |
* 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 remove_payment_plans_when_discount_code_applied( $discount_code, $discount_code_id, $level_id, $code_level ) { | |
// Is payment plans active? | |
if ( ! function_exists( 'pmpropp_get_plan' ) ) { | |
return; | |
} | |
// If a valid discount code is applied, remove payment plans. | |
if ( ! empty( $code_level ) ) { | |
echo 'jQuery("#pmpropp_select_payment_plan").remove();'; | |
} | |
} | |
add_action( 'pmpro_applydiscountcode_return_js', 'remove_payment_plans_when_discount_code_applied', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment