Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Use the below code to simply move the field
- // ===============================================================================
- function my_pmproarc_move_checkout_field() {
- remove_action('pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15);
- add_action( 'pmpro_checkout_after_level_cost', 'pmproarc_pmpro_checkout_boxes', 5 );
- }
- add_action( 'init', 'my_pmproarc_move_checkout_field' );
- // ===============================================================================
- // Use the below code to modify what the field looks like by rewriting the function
- // ===============================================================================
- function my_pmproarc_move_checkout_field() {
- remove_action('pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15);
- add_action( 'pmpro_checkout_after_level_cost', 'my_pmproarc_pmpro_checkout_boxes', 5 );
- }
- add_action( 'init', 'my_pmproarc_move_checkout_field' );
- function my_pmproarc_pmpro_checkout_boxes() {
- global $pmpro_level, $pmpro_review, $discount_code;
- //only for certain levels
- $options = pmproarc_getOptions($pmpro_level->id);
- if(empty($options) || empty($options['setting']))
- return;
- //maybe the level doesn't have a recurring billing amount
- $olevel = pmpro_getLevel($pmpro_level->id);
- if(!pmpro_isLevelRecurring($olevel))
- return;
- //not if this is an addon package
- if(!empty($_REQUEST['ap']) || !empty($_SESSION['ap']))
- return;
- //not if using a discount code
- if(!empty($discount_code) || !empty($_REQUEST['discount_code']))
- return;
- if(isset($_REQUEST['autorenew_present']))
- $autorenew = intval($_REQUEST['autorenew']);
- elseif(isset($_SESSION['autorenew']))
- $autorenew = $_SESSION['autorenew'];
- elseif($options['setting'] == 2)
- $autorenew = 1;
- else
- $autorenew = 0;
- if(!$pmpro_review) {
- ?>
- <div id="pmpro_autorenewal_checkbox" class="pmpro_checkout">
- <hr />
- <h3>
- <span class="pmpro_checkout-h3-name"><?php _e('Would you like to set up automatic renewals?', 'pmproarc');?></span>
- </h3>
- <div class="pmpro_checkout-fields">
- <div class="pmpro_checkout-field-checkbox pmpro_checkout_field-autorenew">
- <input type="checkbox" id="autorenew" name="autorenew" value="1" <?php checked($autorenew, 1);?> />
- <input type="hidden" id="autorenew_present" name="autorenew_present" value="1" />
- <label class="pmprorh_checkbox_label pmpro_clickable" for="autorenew">
- <?php
- //setup a temp level with initial = billing amount so the short level cost text looks nice
- $temp_level = pmpro_getLevel($pmpro_level->id);
- remove_filter("pmpro_checkout_level", "pmproarc_checkout_level", 7);
- $temp_level = apply_filters('pmpro_checkout_level', $temp_level);
- add_filter("pmpro_checkout_level", "pmproarc_checkout_level", 7);
- $temp_level->initial_payment = $temp_level->billing_amount;
- printf(__('Yes, renew at %s', 'pmproarc'), pmpro_getLevelCost($temp_level, false, true));
- ?>
- </label>
- </div> <!-- end pmpro_checkout-field -->
- </div> <!-- end pmpro_checkout-fields -->
- </div> <!-- end pmpro_payment_method -->
- <?php
- } else {
- if(!empty($_SESSION['autorenew']))
- ?>
- <input type="hidden" id="autorenew" name="autorenew" value="<?php echo intval($autorenew);?>" />
- <input type="hidden" id="autorenew_present" name="autorenew_present" value="1" />
- <?php
- }
- }
- // ===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement