-
Notifications
You must be signed in to change notification settings - Fork 2k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkout: Change plan upsell calculation to take volume and discounts into account #90893
Checkout: Change plan upsell calculation to take volume and discounts into account #90893
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~94 bytes added 馃搱 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~94 bytes added 馃搱 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
Also make it clear that `cost_overrides` is always set.
3d2bb87
to
1836036
Compare
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.
Testing with a domain and sale coupon:
The subtotal is $4.84 and the extra price to pay is shown as $26.
The subtotal is now $48, which is a $43.16 increase. This does not match the $26 shown earlier in the upsell.
This issue only happens when the term selected for the domain is 1 year. On longer terms, the upsell shows the correct price.
Thanks for noticing that, @aneeshd16! It turns out that single year domain registration sale coupons were not correctly being recorded as first-year-only. I believe I've fixed that with D149403-code. Can you try again? |
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.
Thanks for fixing this! LGTM.
I don't have the complete context for terms like item_subtotal_integer
and item_original_subtotal_integer
, but logically the change makes sense to me.
Proposed Changes
When you have a domain in your cart and no plan (pre-owned or in the cart), checkout displays an upsell that suggests adding a plan. It includes text that reads either "save X" or "pay an extra X" to inform the user what the price difference would be for their cart with the plan. However, the calculation currently is not accurate if the domain item is for multiple years.
The calculation is inaccurate because of the following reasons:
In this PR we refactor the calculation to cover each of the above cases to better predict the savings or extra cost that will occur when adding a plan to the cart.
It's possible for this calculation to still be incorrect for discount types not covered above (introductory offers, maybe?), but since sale coupons and coupon code are probably the most common discounts applied to domains and wpcom plans, this should cover most scenarios.
Fixes the bug reported here: #89472 (review). That PR was never merged because I accidentally made a very similar refactor around the same time (#89874) for a different purpose which ended up causing the same bug reported in the original PR. Huge apologies to @chriskmnds and @aneeshd16 for that oversight! 馃檱
Screenshots
Here is an example with a sale coupon on the domain. Note the referenced price difference in the "Upgrade and save" box on the right side. Prior to this change, it reads "Save $11.40" and after this change it reads "Pay an extra $32.60". The actual difference in the cart total will be an increase from $59.40 to $92.00, an increase of $32.60.
For reference, here's what my cart looks like after I accept the upsell:
Here is another example with a coupon code instead of a sale coupon (a cart cannot have both at the same time). Note that the "Pay an extra X" now includes the 50% savings from the coupon. Prior to this change it read "Pay an extra $42" and after this change it reads "Pay an extra $18". The actual difference in the cart total will be an increase from $6 to $24, a difference of $18.
Here's what the cart looks like after the upsell:
Testing Instructions
It's a good idea to test this for a domain with a sale coupon and a domain without a sale coupon. It's also a good idea to try adding a coupon code to make sure the prices are still accurate.