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
Reported by @allie500 in p1731683240284119-slack-C055WHLA98D:
A merchant has reported an issue with applying a sign up % discount coupon when a shopper with an active subscription of a variable subscription product switches to a new variation with a sign up fee. The coupon percentage is not applied to the sign up fee.
The HE who escalated the issue to Woo-Devs was able to replicate the issue. I spun up a JN site and was also able to replicate the issue. I also didn't see anything relevant in the debug.log file nor the wc-logs.
When I applied the coupon no exception or errors were thrown. The coupon was showing up on the page but the percentage amount was not deducted from the sign up fee.
Processing the order resulted in the full sign up fee being charged. I checked the coupons page in the wp-admin and it shows that the coupon has one usage.
To Reproduce
Go to the coupon page in the wp-admin and make note of the current usage number for the coupon.
Buy the annual variation of the subscription.
Confirm the order was successful.
Then on the my account page go to the subscriptions subpage and click the upgrade or downgrade button.
Select the lifetime variation.
Apply the coupon: lifetime20
Observe that the amount due is not updated to reflect a 20% discount on the sign up price.
Observe that the coupon is successfully added to the order.
Finish checkout.
Go to the coupons page in the wp-admin and confirm that the number incremented.
Expected behavior
Sign up fee coupons get applied when upgrading/downgrading subscriptions.
Actual behavior
Sign up fee coupons get ignored when upgrading/downgrading subscriptions.
Product impact
Does this issue affect WooCommerce Subscriptions? yes
Does this issue affect WooCommerce Payments? no
Additional context
Initial investigation by @annemirasol traced the behavior to
Thanks @annemirasol for opening an issue. Calculating sign-up fee discounts on a switch item may be difficult because after calculating the upgrade costs of the switch, we set the upgrade cost as the signup fee on the cart item. See set_upgrade_cost()
Part of the challenge is ensuring we calculate the correct discount_amount based on our "Prorate Sign Up Fee" setting:
Thinking out aloud here... inside our class-wc-subscriptions-coupon.php class, we are getting the signup fee using WC_Subscriptions_Product::get_sign_up_fee( $cart_item['data'] ) which will return $existing_sign_up_fee + $extra_to_pay (set by set_upgrade_cost()).
Because we don't want the discount to apply to the switch upgrade cost, what we might be refactor our get_discount_amount_for_cart_item() function to fetch the correct signup fee when calculating the signup and discount amounts here.
Correct sign-up fee amount to use:
For switches, use $cart_item['data']->get_meta( '_subscription_sign_up_fee_prorated' ); if it exists.
In all other cases, we should be able to use WC_Subscriptions_Product::get_sign_up_fee( $cart_item['data'] )
Describe the bug
Reported by @allie500 in p1731683240284119-slack-C055WHLA98D:
A merchant has reported an issue with applying a sign up % discount coupon when a shopper with an active subscription of a variable subscription product switches to a new variation with a sign up fee. The coupon percentage is not applied to the sign up fee.
The HE who escalated the issue to Woo-Devs was able to replicate the issue. I spun up a JN site and was also able to replicate the issue. I also didn't see anything relevant in the debug.log file nor the wc-logs.
When I applied the coupon no exception or errors were thrown. The coupon was showing up on the page but the percentage amount was not deducted from the sign up fee.
Processing the order resulted in the full sign up fee being charged. I checked the coupons page in the wp-admin and it shows that the coupon has one usage.
To Reproduce
Expected behavior
Sign up fee coupons get applied when upgrading/downgrading subscriptions.
Actual behavior
Sign up fee coupons get ignored when upgrading/downgrading subscriptions.
Product impact
Additional context
Initial investigation by @annemirasol traced the behavior to
woocommerce-subscriptions-core/includes/class-wc-subscriptions-coupon.php
Line 223 in 07bf070
The text was updated successfully, but these errors were encountered: