Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PMPro Sponsored Members Example with custom callback to override seat pricing.
/**
* Sponsored Members setup with child seat costs and child fields at checkout.
*/
global $pmprosm_sponsored_account_levels;
$pmprosm_sponsored_account_levels = array(
1 => array(
'main_level_id' => 1,
'sponsored_level_id' => 2,
'seat_cost' => 35,
'min_seats' => 1,
'max_seats' => 10,
'sponsored_accounts_at_checkout' => true,
'seat_cost_text' => '<br />Total cost will be $200 for 1 seat, $270 for up to 3, $340 for up to 5, $445 for up to 10.',
)
);
/**
* Remove Sponsored Members Pricing update and use our own.
*/
function my_init_override_sponsored_members_pricing_update() {
remove_filter( 'pmpro_checkout_level', 'pmprosm_pmpro_checkout_levels' );
add_filter( 'pmpro_checkout_level', 'my_custom_pmpro_seat_pricing' );
}
add_action( 'init', 'my_init_override_sponsored_members_pricing_update' );
/**
* My custom pricing.
*/
function my_custom_pmpro_seat_pricing( $level ) {
// Only concerned about level 1
if ( $level->id != 1 ) {
return $level;
}
// get seats from submit
if ( isset( $_REQUEST['seats'] ) )
$seats = intval($_REQUEST['seats']);
else
$seats = "";
switch ( $seats ) {
case $seats < 2:
// use level price
break;
case $seats <= 3:
$level->initial_payment = $level->initial_payment + 70;
$level->billing_amount = $level->billing_amount + 70;
break;
case $seats <= 5:
$level->initial_payment = $level->initial_payment + 140;
$level->billing_amount = $level->billing_amount + 140;
break;
case $seats <= 10:
$level->initial_payment = $level->initial_payment + 245;
$level->billing_amount = $level->billing_amount + 245;
break;
}
return $level;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.