-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect users to /domains/add when cart is cleared in EmailUpsell flow. #98519
base: trunk
Are you sure you want to change the base?
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 (~98 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 (~225 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. |
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
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.
This looks like an elegant solution! Thanks for all the research on the different alternatives. I was wondering, since this seems to focus on leaving checkout using the masterbar close button, does this same bug exist if you remove the product from your cart manually in checkout (which also redirects away if it's the last cart item)?
Aha! Thanks for catching that. I've fixed that in 7ee9365. |
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.
Looks good! I made one request for the API of closeAndLeave
but it's not a blocker.
Fixes: #84228
Proposed Changes
When a user clears their cart at checkout after coming from the domainEmail upsell flow, they encounter an error when attempting to add an email after being redirected there.
This PR updates
leaveCheckout
to return users to/domain/add
if they have cleared their cart and are coming from the Email Upsell flow.Changes:
userHasClearedCart
toleaveCheckout
to determine whether the user has chosen to clear their cart.getCloseURL
function to encapsulatecloseUrl
logic./domain/add
if users have cleared their cart.Why are these changes being made?
Ideally, we wouldn't need to add flow-specific logic to
leaveCheckout
. It would be best to redirect users who arrive on/domains/add/{domain}/email/{site}
before rendering the page.Currently when users clear their cart, we call replaceProductsInCart and immediately redirect the user. Often, users arrive at their next route before the cart has fully cleared. We therefore can't simply check the cart early and redirect. They EmailUpsell view will flash.
We therefore have three choices:
replaceProductsInCart
synchronously, then check cart on upsell page load.Run
replaceProductsInCart
synchronouslyUnfortunately, this doesn't work because users will see the empty cart state flash before they are redirected.
Suspend rendering the email upsell
This approach is more predictable and how other pages in upsells flows work. However, this will introduce more delays in rendering the page. As it is, the email upsell page loads fast and is snappy. This is a much better experience for upsells. We don't want users to wait for an upsell they may not want.
Direct users in leaveCheckout [Implemented in this PR]
I went with this approach. If feels like the quickest win that doesn't add delays in the purchase flow or introduce any large refactors.
It isn't without some compromise though.
I decided to use a regex to determine if the users came from the domain flow. I considered using domainAddEmailUpsell but since we don't have access to
context.params
to determine the domain the were adding, I didn't see an easy way to compare the URLs. There may be a way to do it with the flow name but that also requires access tocontext
or maybe there's a way to get the context?There's also one use case that isn't handled. If a user clears their cart but makes their way back to the upsell page, they will get an error if they add an email. I don't think that use case would be common and I'm not convinced we need to handle it.
Testing Instructions
Using an account with no domain yet.
Test Emptying Cart
Upgrade->Domains
click "Just search for a domain"/domains/add
Test Leave Items in Cart
Upgrade->Domains
click "Just search for a domain"Test Add Plan flow, empty cart
Upgrade->Plans
click "Upgrade" on a planRe-run the test but choose "Leave Items" in cart, expect the same result.
Pre-merge Checklist