Skip to content
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

Gifting: Remove all gift products from the cart whenever one is removed #70529

Merged
merged 2 commits into from
Nov 30, 2022

Conversation

DavidRothstein
Copy link
Contributor

Proposed Changes

Subscription gifts need to be all or nothing -- for example, if someone manages to gift a plan renewal but not the corresponding primary domain renewal that was automatically added to the shopping cart, then the site would likely break when the domain expires, so it would have wound up being a confusing and not very useful gift.

Currently, this is mostly enforced on the server, but the user experience is bad -- for example, trying to remove the gift domain renewal from the cart does nothing (pdtkmj-Ks-p2#comment-1269).

This pull request makes it so removing any gift product from the cart automatically removes all the others, and changes the confirmation message for removing a gift (which previously didn't quite make sense for someone gifting a subscription to someone else's site) to match.

Before (removing a plan or domain, and in some cases the removal wouldn't actually work after you press "Continue"):

remove-plan-before
remove-domain-before

After (removing either the plan or the domain):

remove-gift-after

Testing Instructions

The easiest way to test this is to have a site with a Personal plan and custom domain, where the custom domain is set to primary, and where subscription gifting is turned on via /settings/general/.

Log in as a different user, and visit a URL like /checkout/personal-bundle/gift/[ID], where ID is the subscription ID (obtained from the server, or from the number in the URL when the original user clicks through to manage their subscription from the Purchases page). This should put the plan and domain renewal in your shopping cart as a gift.

Test that if you go to remove either the plan or domain from the cart, the expected confirmation message is shown, and that going through with the removal causes both products to be removed from the cart and the cart to be emptied.

Pre-merge Checklist

  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@DavidRothstein DavidRothstein added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 29, 2022
@DavidRothstein DavidRothstein requested a review from a team as a code owner November 29, 2022 14:36
@DavidRothstein DavidRothstein self-assigned this Nov 29, 2022
@github-actions
Copy link

github-actions bot commented Nov 29, 2022

@matticbot
Copy link
Contributor

matticbot commented Nov 29, 2022

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~102 bytes added 📈 [gzipped])

name      parsed_size           gzip_size
checkout       +377 B  (+0.0%)     +102 B  (+0.0%)

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 (~102 bytes added 📈 [gzipped])

name                                              parsed_size           gzip_size
async-load-masterbar-cart-masterbar-cart-wrapper       +377 B  (+0.4%)     +102 B  (+0.3%)
async-load-calypso-my-sites-checkout-modal             +377 B  (+0.0%)     +102 B  (+0.0%)
async-load-calypso-blocks-editor-checkout-modal        +377 B  (+0.0%)     +102 B  (+0.0%)

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Member

@sirbrillig sirbrillig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and it works as described!

Copy link
Contributor

@pottedmeat pottedmeat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good

@DavidRothstein DavidRothstein merged commit aee9bca into trunk Nov 30, 2022
@DavidRothstein DavidRothstein deleted the fix/remove-gift-products branch November 30, 2022 22:27
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 30, 2022
@a8ci18n
Copy link

a8ci18n commented Dec 1, 2022

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7648480

Thank you @DavidRothstein for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Dec 11, 2022

Translation for this Pull Request has now been finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants