Created
May 8, 2024 01:51
-
-
Save andrewlimaza/807c22da7e13ff9fe65239f789ddeb9f to your computer and use it in GitHub Desktop.
Adjust Variable Pricing Add On Text for recurring levels.
This file contains 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 | |
/** | |
* Add recurring text after Variable Pricing text. | |
* Tweak the wording for your needs. | |
* | |
* To add this code to your site please visit - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_vp_text_adjustment( $text ) { | |
$level = pmpro_getLevelAtCheckout(); | |
// We don't need to show extra information if there is no billing amount and assume a one time charge. | |
if ( $level->billing_amount == 0 ) { | |
return $text; | |
} | |
// Add some text afterwards to say that the user will be charged recurring. | |
if ( $level->cycle_number > 1 ) { | |
$text .= ' You will be charged every ' . $level->cycle_number . ' ' . $level->cycle_period . '.'; // i.e. You will be charged every 3 Months. | |
} else { | |
$text .= ' You will be charged every ' . $level->cycle_period . '.'; // i.e. You will be charged every month. | |
} | |
return $text; | |
} | |
add_filter( 'pmpropvp_checkout_price_description', 'my_pmpro_vp_text_adjustment' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment