You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The /sales/ endpoint includes a discounts array, which is meant to contain the total discount amount (flat dollar amount) for that order. I expect this number to be accurate.
Actual behavior
When using variable prices and purchasing not the cheapest price option, the discount amount is incorrect.
Steps to reproduce the behavior
Create a variable price product with at least two price options. For example: $3 and $10.
Create a discount code. In my tests I used 25%, but setting isn't relevant.
Purchase the higher priced option. So, $10.
View the output of the /sales/ API endpoint. Look at the discounts array. This amount is incorrect.
In my example:
I purchased a $10 product with a 25% off discount.
The discounts array shows: array( 'discounts' => 0.75 ). That 0.75 would be correct if I'd purchased the cheapest ($3) price option. But since I purchased $10, it should have been 2.5
Bug Report
Expected behavior
The
/sales/
endpoint includes adiscounts
array, which is meant to contain the total discount amount (flat dollar amount) for that order. I expect this number to be accurate.Actual behavior
When using variable prices and purchasing not the cheapest price option, the discount amount is incorrect.
Steps to reproduce the behavior
/sales/
API endpoint. Look at thediscounts
array. This amount is incorrect.In my example:
discounts
array shows:array( 'discounts' => 0.75 )
. That 0.75 would be correct if I'd purchased the cheapest ($3) price option. But since I purchased $10, it should have been2.5
Information (if a specific version is affected):
PHP Version:
EDD Version (or branch): master
WordPress Version:
Any other relevant information:
The issue is that the
options
array in cart details isn't being properly passed through to the discount functions. In the API we useedd_get_cart_item_discount_amount()
here: https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/api/class-edd-api-v2.php#L451The structure of
$item
looks like this:Note how
options
is nested insideitem_number
.But when you dig through
edd_get_cart_item_discount_amount()
, it looks foroptions
inside$item['options']
directly https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/cart/class-edd-cart.php#L645 Which means it's never getting picked up and falls back to using theedd_price
meta, which, with variable pricing enabled, is defaulted to the cheapest option.The text was updated successfully, but these errors were encountered: