Incorrect total discount for inital cart pseudo coupon if there are multiple subscriptions in cart #755
Open
Description
Describe the bug
Initially reported in p1735654651089199-slack-C7U3Y3VMY
When the cart has a pseudo coupon applied (i.e. by manually deducting from the cart total in wp-admin), and the cart contains more than 1 subscription, the total discount amount gets incorrectly treated as "per sub" instead of "per cart".
In the example below, a 10.00 cart discount was manually applied. The Pay for Order page redirects to the checkout page which creates a pseudo coupon for 50.00 instead of 10.00.
To Reproduce
- In WooCommerce > Subscriptions, manually crate a new subscription.
- Select an existing shopper that you can log in as.
- For Quantity, enter a number > 1, e.g. 5.
- Under Order Actions, click "Create pending parent order".
- Go to the parent order.
- Edit the cart total, subtracting a few dollars from it. Do not make the total 0.00.
- Copy the "Customer payment page" link.
- As the logged in shopper in a separate browser, open the payment link.
- You will notice that the cart total is incorrect. (The cart discount has been multiplied by the subscription quantity.)
- Go back to the parent order page in wp-admin and refresh it.
- You will see a "discount_intial" coupon has been added to the order. Hover over the coupon and notice that the coupon amount is incorrect.
Expected behavior
The cart discount should not be multiplied by item quantity.
Actual behavior
The cart discount gets multiplied by item quantity, leading to an incorrect cart total.
Product impact
- Does this issue affect WooCommerce Subscriptions? yes
- Does this issue affect WooCommerce Payments? no