-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for signup fee coupons during subscription switches #751
base: trunk
Are you sure you want to change the base?
Conversation
5fcdaa5
to
ed0c575
Compare
ed0c575
to
912d4dc
Compare
0095552
to
7e79332
Compare
This reverts commit 7e79332.
@mattallan Thank you again for the pointers. Added you as reviewer, for extra 👀 |
$sign_up_fee_prorated = (int) $cart_item['data']->get_meta( '_subscription_sign_up_fee_prorated' ); | ||
$price_prorated = (int) $cart_item['data']->get_meta( '_subscription_price_prorated' ); | ||
|
||
if ( 0 === $sign_up_fee_prorated && 0 === $price_prorated ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question for my understanding - why the price_prorated
is also being checked here? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! In 3ee2abc, I simplified the logic using meta_exists
. Hopefully it's more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have come across a confusing scenario.
- I created 2 coupons
- a signup fee % discount for 20% (signup percent)
- a signup fee discount for 10 (signup 10)
- I created a variable subscription 'Membership Tier' as mentioned in the PR description but with different signup fees.
- Regular with a signup fee 5.
- Premium with a signup fee 10.
Case 1:
- Purchased the 'Regular' variation.
- Upgraded to 'Premium' and went to the checkout page.
- The signup fee is 30 (not 10) 🤔
- Used the
signup percent
coupon. The amount is -2. (This is the correct percentage for signup fee 10 but why does it show 30 here? ) - Used the
signup 10
coupon. The amount is -10. (also correct caps for signup fee 10) - In this case the sign up fee is off. Also with multiple coupons used, the discount is more than the sign up fee.
Case 2:
- Purchased the 'Premium' variation.
- Downgraded to 'Regular' and went to the checkout page.
- Used the
signup 10
coupon. The amount is -5. (also correct) - Used the
signup percent
coupon. The amount is 0. (If I remove the previous coupon the discount becomes -1 which is correct) - In this case, is it the expected behavior for multiple coupons.
Did you set recurring fees to be prorated, and signup to be charged full amount? If that is the case, the signup fee displayed is 30 because it is 10 (the true signup fee) + 20 (the difference between Regular and Premium). The signup fee being 30.00 is part of the issue why signup fee coupons are currently not supported. In this function, we overwrite the true signup fee with (true signup fee + upgrade costs from the recurring fee difference).
Good catch! I need to add logic for when multiple coupons are used. |
I checked the sign up fee coupon behavior for initial subscription purchases, and the behavior seems to be the same: multiple sign up fee coupons applied to the same cart can lead to a total discount that is greater than the actual sign up fee. @mattallan Is this a known issue, or a non-issue/expected behavior? |
Fixes #726
Description
This PR adds support for signup fee coupon during subscription switches. It computes for the actual signup fee amount and applies the discount to that amount.
How to test this PR
Allow Switching: Between Subscription Variations
.For Upgrades and Downgrades of All Subscription Products
Never (charge the full signup fee)
Used for variations
before saving.Prorate Recurring Payment
andProrate Signup Fee
: no matter the combination, the discount amount should never be more than 1.00.Product impact