Discount code amount is shown but total shows non-discount price so transaction fails #9698
Labels
type-bug
workflow-needs-replication
workflow-pending-triage
Items that need to be triaged and reviewed before they are worked on.
This issue remains, please see for reference => #9594
Using the add_download function is not calculating applied discounts correctly.
The following function checks to see if the user has already received a freebie item and, if not, adds the item to their order. The item is free, but is it recalculating the total and not taking possible discounts into consideration.
To reproduce:
Install EDD
Create dummy product (Awesome Product) for $9.99 (price irrelevant)
Create dummy product (Free Product) for $0.00 (again, price irrelevant)
Create discount code for 40% off (Code: BLACK)
Add the following to functions.php (changing product IDs to Free Product ID :
Add Awesome Product $9.99 to Cart
Add discount code BLACK to order (discount will be reflected in order)
Complete Checkout
Now order will complete. Chained download is successfully added to order. But if you look at the order, the discount shows, but the total is incorrect, regardless if the product is free or not, which causes payment failed on production.
I added error_log(print_r($payment->total, true)); in two places in the function (currently commented out), which prints the total before and after the add_download into the error log. The first total is correct, the second is missing the discount.
I have also tested by adding $args and changing the price from 0.00 to 1.00, with the same result.
The text was updated successfully, but these errors were encountered: