Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimcoleman/f9bf2d35dc4786558996dc751f2be762 to your computer and use it in GitHub Desktop.
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/
<?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