When you attempt to pay for a failed parent order where prices are inclusive of tax and there's a discount that applied, the total that appears on the checkout would be incorrect.
After some digging I discovered it's because we're pulling the order discount amount excluding tax so a $10 discount, for example, would be returned as $9.62. The customer would then only be discounted $9.62 not the full $10.
This PR fixes it.
How to test this PR
Create a recurring discount of $10 in Marketing → Discounts.
Create a $50 subscription product of any recurring frequency.
In WooCommerce → General settings make sure tax calculations are enabled.
In WooCommerce → Settings → Taxes make sure prices are inclusive of tax.
Disable shipping or add a free shipping method.
Add a 4% tax rate that applies.
Add the product to your cart.
Apply the coupon.
Note that the total is $40 with $1.54 tax.
Fail the payment using a Stripe test card like: 4000000000000002
Go to the My Account > Orders page and attempt to pay for the order.
On trunk you'll notice that a discount of $9.62.
On this branch it should be correctly $10 with a total of $40.
trunk
This branch
[!NOTE]
I've tested this with prices exclusive of tax and with % discounts and they also work with this change also works for those scenarios too.
Product impact
[x] Added changelog entry (or does not apply)
[ ] Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
[ ] Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
[ ] Added deprecated functions, hooks or classes to the spreadsheet
Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4227
Description
When you attempt to pay for a failed parent order where prices are inclusive of tax and there's a discount that applied, the total that appears on the checkout would be incorrect.
After some digging I discovered it's because we're pulling the order discount amount excluding tax so a $10 discount, for example, would be returned as $9.62. The customer would then only be discounted $9.62 not the full $10.
This PR fixes it.
How to test this PR
4000000000000002
trunk
you'll notice that a discount of $9.62.trunk
Product impact