Last active
July 31, 2019 17:44
-
-
Save femiyb/82c3e1f10827779aec528539ef0ca36b to your computer and use it in GitHub Desktop.
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 | |
| function my_pmprorh_init_2() | |
| { | |
| //don't break if Register Helper is not loaded | |
| if(!function_exists("pmprorh_add_registration_field")) | |
| { | |
| return false; | |
| } | |
| $fields = array(); | |
| $fields[] = new PMProRH_Field( | |
| 'gallery_page', | |
| 'checkbox', | |
| array( | |
| 'label' => 'Add Gallery Page', | |
| 'profile' => true, | |
| ) | |
| ); | |
| //add the fields into a new checkout_boxes are of the checkout page | |
| foreach($fields as $field) | |
| pmprorh_add_registration_field( | |
| "checkout_boxes", // location on checkout page | |
| $field // PMProRH_Field object | |
| ); | |
| //that's it. see the PMPro Register Helper readme for more information and examples. | |
| } | |
| add_action("init", "my_pmprorh_init_2"); | |
| /* | |
| If a user checked option1, then add $100 to the price. | |
| */ | |
| function my_pmpro_checkout_level($level) | |
| { | |
| if(!empty($_REQUEST['gallery_page'])){ | |
| if($level->id == 1) | |
| { | |
| $level->initial_payment = $level->initial_payment + 18; | |
| $level->billing_amount = $level->billing_amount + 18; //to update recurring payments too | |
| } elseif ($level->id == 2) { | |
| $level->initial_payment = $level->initial_payment + 4.50; | |
| $level->billing_amount = $level->billing_amount + 4.50; //to update recurring payments too | |
| } else { | |
| $level->initial_payment = $level->initial_payment + 1.50; | |
| $level->billing_amount = $level->billing_amount + 1.50; //to update recurring payments too | |
| } | |
| } | |
| return $level; | |
| } | |
| add_filter("pmpro_checkout_level", "my_pmpro_checkout_level"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment