Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created August 18, 2014 03:39
Show Gist options
  • Select an option

  • Save dancameron/fba1015b9093e2cdc8ae to your computer and use it in GitHub Desktop.

Select an option

Save dancameron/fba1015b9093e2cdc8ae to your computer and use it in GitHub Desktop.
Fix for Recurring EDD Payments with Discounts (Paypal).
<?php
// filter paypal because of discount
function sa_mod_paypal_gateway_data( $paypal_args = array(), $purchase_data = array() ) {
if ( isset( $paypal_args['cmd'] ) && $paypal_args['cmd'] == '_xclick-subscriptions' ) {
$paypal_args['sra'] = '3'; // change failed attempts.
if ( $paypal_args['a3'] < 0.00 && isset( $purchase_data['discount'] ) ) {
// Fix recurring amount
$paypal_args['a3'] += $purchase_data['discount'];
// fix single item, it matches the recurring amount.
$paypal_args['amount_1'] += $purchase_data['discount'];
// Add the discount
// $paypal_args['discount_amount_cart'] = $purchase_data['discount'];
}
}
return $paypal_args;
}
add_filter( 'edd_paypal_redirect_args', 'sa_mod_paypal_gateway_data', 100, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment