Skip to content
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

3.0 - Discounts are not being stored correctly in the adjustments table #8511

Closed
robincornett opened this issue Mar 23, 2021 · 0 comments · Fixed by #8512
Closed

3.0 - Discounts are not being stored correctly in the adjustments table #8511

robincornett opened this issue Mar 23, 2021 · 0 comments · Fixed by #8512
Labels
Milestone

Comments

@robincornett
Copy link
Contributor

robincornett commented Mar 23, 2021

Bug Report

Expected behavior

When I purchase a variably priced product with a percentage based discount, I expect the discount subtotal/total amounts to be correct in the adjustments database table.

Actual behavior

The discount is not calculated correctly and is either 0, or if a non-variable product is in the order, the discount is the amount for just the one item.

Steps to reproduce the behavior

  1. Create a product with variable pricing.
  2. Create a percentage based discount.
  3. Add the variable product to your order and apply the discount.
  4. Complete the order.
  5. Note that the receipt appears to show the correct information and totals. However, if you check the edd_order_adjustments table for that order ID, the discount amount is incorrect. Additionally, when you go to edit the order in the admin, the discount does not show correctly, as it's calculated from the database, not the payment object (the receipt uses old payment functions 3.0 - update receipt shortcode template to use order object #8508).

Information (if a specific version is affected):

PHP Version: 7.4
EDD Version (or branch): release/3.0
WordPress Version: 5.7

Any other relevant information:
I'm not sure if the issue is in the edd_get_item_discount_amount function or in how the cart_details are built, but I think the failure point is here:

https://github.com/easydigitaldownloads/easy-digital-downloads/blob/af1e1439ff1eb60443bcd5cd8460f091bcaaaa0c/includes/discount-functions.php#L1028-L1030

It looks like a similar issue was fixed in the cart for 2.10 in issue #8246, in which case we need to apply the same fix to the edd_get_item_discount_amount function.

This also affects an open PR in Invoices to show discounts.

Note: marking for beta2 as it's also affecting #8075.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants