Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <?php
  2. /*
  3. * This gist adds recurring functionality to the Donations Add On for Paid Memberships Pro.
  4. * It adds the user-entered 'donation amount' to their recurring billing amount.
  5. */
  6.  
  7. //add donation amount to recurring payment amount
  8. function pmprodon_pmpro_donation_recurring( $level ) {
  9. if( isset( $_REQUEST['donation'] ) ) {
  10. $donation = preg_replace( '[^0-9\.]', '', $_REQUEST['donation'] );
  11. } else {
  12. return $level;
  13. }
  14. if( !empty( $donation ) ) {
  15. //save initial payment amount
  16. global $pmprodon_original_initial_payment;
  17. $pmprodon_original_initial_payment = $level->billing_amount;
  18.  
  19. //add donation
  20. $level->billing_amount = $level->billing_amount + $donation;
  21. }
  22. return $level;
  23. }
  24. add_filter( 'pmpro_checkout_level', 'pmprodon_pmpro_donation_recurring', 99 );
Add Comment
Please, Sign In to add comment