Fix issues with discounts being applied to manually created parent orders #439
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes woocommerce-subscriptions/issues/4504
🛑 This PR is on-hold while more work and testing is done. I've submitted it as a draft for now.
Description
When you apply a coupon to a subscription manually and then pay for a newly created subscription parent order, the discount is supposed to be copied into into the cart as a coupon. Because of a rounding discrepancy with how WC core stores coupon line item totals and order discounts, this was not working as intended. What's more, because this wasn't working as intended, customers would end up in a flow that had even more issues.
This PR fixes those issues. Namely:
How to test this PR
Set up:
8. On
trunk
the order total will be incorrect ($5.46) and the recurring cart won't have the coupon applied.9. On this branch the total should be correct and the coupon should apply to both the initial amount and recurring cart.
Further tests should be ran to make sure different tax, amounts and ways of applying discounts to parent orders and subscriptions should be tested.
Product impact