-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negative Fees are applied again in PayPal Standard #6837
Comments
I've updated the title. Since your example mentions using the Fees API. |
@arturi, can you provide the exact call to the Fees API you are using? Including all the arguments, so we can try and replicate the exact situation you are seeing. |
Thanks for the quick reply! ...
function apply_discount($total_discount_ammount) {
if ($total_discount_ammount != 0) {
EDD()->fees->add_fee($total_discount_ammount, 'Discount', 'b_edd_discount_' . time());
}
}
function calculate_discounts() {
$cart_contents = (edd_get_cart_contents());
if ($cart_contents) {
remove_duplicate_items($cart_contents);
remove_all_fees();
$total_discount_ammount = multiple_licences_discount($cart_contents) + multiple_styles_discount($cart_contents) + full_family_licences_discount($cart_contents);
apply_discount($total_discount_ammount);
}
}
add_action('init', 'calculate_discounts'); |
More information / duplicates: #7163 This affects RCP Member Discounts and likely also Discounts Pro. Steps to reproduce with RCP Member Discounts (not sure if exact numbers matter, but including my settings, which I copied from a customer):
As a few others have already pointed out, the issue is that
At this point: https://github.com/easydigitaldownloads/easy-digital-downloads/blob/74905fe92666c7b79e65d9db6b8e60e71912a7e3/includes/gateways/paypal-standard.php#L287 We make it into this if statement: https://github.com/easydigitaldownloads/easy-digital-downloads/blob/74905fe92666c7b79e65d9db6b8e60e71912a7e3/includes/gateways/paypal-standard.php#L296 because |
I replicated the issue with EDD I was not able to replicate the Discounts Pro issue this time. |
Thank you @dgoldak ! |
Prevent negative fees from getting applied twice #6837
Bug Report
Expected behavior
When a discount is applied to total amount, it’s calculated in EDD, and then the discounted amount is passed to PayPal as is. Total amount is the same number between EDD and PayPal.
Actual behavior
When I add discounts via
EDD()->fees->add_fee()
, everything is shown correctly in cart and Purchase History, but thenPayPal Standard
calculates and adds the discount again. So total of $80 with a discount of -$20 shows as total $60 in cart, but then becomes $40 in PayPal.This started happening recently when I upgraded EDD from
2.2.8
to2.9.3
. If I comment out the linehttps://github.com/easydigitaldownloads/easy-digital-downloads/blob/74905fe92666c7b79e65d9db6b8e60e71912a7e3/includes/gateways/paypal-standard.php#L292-L294
everything works as expected / as it used to. I’m hoping you can recognize the issue and tell me what I might be doing wrong, if this is not a bug.
Thank you for EDD and for the help!
Information (if a specific version is affected):
PHP Version: 5.6.32-5.6.32+mh2
EDD Version (or branch): 2.9.3
WordPress Version: 4.9.8
The text was updated successfully, but these errors were encountered: