Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. <?php
  2.  
  3. // Use the below code to simply move the field
  4. // ===============================================================================
  5. function my_pmproarc_move_checkout_field() {
  6. remove_action('pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15);
  7. add_action( 'pmpro_checkout_after_level_cost', 'pmproarc_pmpro_checkout_boxes', 5 );
  8. }
  9. add_action( 'init', 'my_pmproarc_move_checkout_field' );
  10. // ===============================================================================
  11.  
  12.  
  13.  
  14. // Use the below code to modify what the field looks like by rewriting the function
  15. // ===============================================================================
  16. function my_pmproarc_move_checkout_field() {
  17. remove_action('pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15);
  18. add_action( 'pmpro_checkout_after_level_cost', 'my_pmproarc_pmpro_checkout_boxes', 5 );
  19. }
  20. add_action( 'init', 'my_pmproarc_move_checkout_field' );
  21.  
  22. function my_pmproarc_pmpro_checkout_boxes() {
  23. global $pmpro_level, $pmpro_review, $discount_code;
  24.  
  25. //only for certain levels
  26. $options = pmproarc_getOptions($pmpro_level->id);
  27.  
  28. if(empty($options) || empty($options['setting']))
  29. return;
  30.  
  31. //maybe the level doesn't have a recurring billing amount
  32. $olevel = pmpro_getLevel($pmpro_level->id);
  33. if(!pmpro_isLevelRecurring($olevel))
  34. return;
  35.  
  36. //not if this is an addon package
  37. if(!empty($_REQUEST['ap']) || !empty($_SESSION['ap']))
  38. return;
  39.  
  40. //not if using a discount code
  41. if(!empty($discount_code) || !empty($_REQUEST['discount_code']))
  42. return;
  43.  
  44. if(isset($_REQUEST['autorenew_present']))
  45. $autorenew = intval($_REQUEST['autorenew']);
  46. elseif(isset($_SESSION['autorenew']))
  47. $autorenew = $_SESSION['autorenew'];
  48. elseif($options['setting'] == 2)
  49. $autorenew = 1;
  50. else
  51. $autorenew = 0;
  52.  
  53. if(!$pmpro_review) {
  54. ?>
  55. <div id="pmpro_autorenewal_checkbox" class="pmpro_checkout">
  56. <hr />
  57. <h3>
  58. <span class="pmpro_checkout-h3-name"><?php _e('Would you like to set up automatic renewals?', 'pmproarc');?></span>
  59. </h3>
  60. <div class="pmpro_checkout-fields">
  61. <div class="pmpro_checkout-field-checkbox pmpro_checkout_field-autorenew">
  62. <input type="checkbox" id="autorenew" name="autorenew" value="1" <?php checked($autorenew, 1);?> />
  63. <input type="hidden" id="autorenew_present" name="autorenew_present" value="1" />
  64. <label class="pmprorh_checkbox_label pmpro_clickable" for="autorenew">
  65. <?php
  66. //setup a temp level with initial = billing amount so the short level cost text looks nice
  67. $temp_level = pmpro_getLevel($pmpro_level->id);
  68. remove_filter("pmpro_checkout_level", "pmproarc_checkout_level", 7);
  69. $temp_level = apply_filters('pmpro_checkout_level', $temp_level);
  70. add_filter("pmpro_checkout_level", "pmproarc_checkout_level", 7);
  71. $temp_level->initial_payment = $temp_level->billing_amount;
  72. printf(__('Yes, renew at %s', 'pmproarc'), pmpro_getLevelCost($temp_level, false, true));
  73. ?>
  74. </label>
  75. </div> <!-- end pmpro_checkout-field -->
  76. </div> <!-- end pmpro_checkout-fields -->
  77. </div> <!-- end pmpro_payment_method -->
  78. <?php
  79. } else {
  80. if(!empty($_SESSION['autorenew']))
  81. ?>
  82. <input type="hidden" id="autorenew" name="autorenew" value="<?php echo intval($autorenew);?>" />
  83. <input type="hidden" id="autorenew_present" name="autorenew_present" value="1" />
  84. <?php
  85. }
  86. }
  87. // ===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement