Forked from andrewlimaza/pmpro-recurring-donations.php
Last active
January 22, 2022 12:03
-
-
Save kimcoleman/f9bf2d35dc4786558996dc751f2be762 to your computer and use it in GitHub Desktop.
Adds recurring donation functionality to the Donations Add On for Paid Memberships Pro: https://www.paidmembershipspro.com/add-ons/donations-add-on/
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 | |
/* | |
* This gist adds recurring functionality to the Donations Add On for Paid Memberships Pro. | |
* It adds the user-entered 'donation amount' to their recurring billing amount. | |
*/ | |
//add donation amount to recurring payment amount | |
function pmprodon_pmpro_donation_recurring( $level ) { | |
if( isset( $_REQUEST['donation'] ) ) { | |
$donation = preg_replace( '[^0-9\.]', '', $_REQUEST['donation'] ); | |
} else { | |
return $level; | |
} | |
if( !empty( $donation ) ) { | |
//save initial payment amount | |
global $pmprodon_original_initial_payment; | |
$pmprodon_original_initial_payment = $level->billing_amount; | |
//add donation | |
$level->billing_amount = $level->billing_amount + $donation; | |
} | |
return $level; | |
} | |
add_filter( 'pmpro_checkout_level', 'pmprodon_pmpro_donation_recurring', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment