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

composite-checkout: Fix discounted price in variant picker #43126

Merged
merged 6 commits into from
Jun 11, 2020

Conversation

sirbrillig
Copy link
Member

@sirbrillig sirbrillig commented Jun 9, 2020

Changes proposed in this Pull Request

In #42723 I added a bunch of query components from old checkout to new checkout, including QuerySitePlans, but I accidentally added them to renderContactDetails instead of the output of CompositeCheckout. One result of this is that the state.sites.plans Redux state was not populated, which meant that the local data used to determine if a plan should receive a prorated discount was not available. In new checkout, that data is used only for the plan variant selector (all the rest of the prices come from the shopping cart endpoint) and so the selector is showing the un-discounted price for each plan variant.

Screen Shot 2020-06-09 at 4 35 08 PM

This PR moves the Query components to their correct location, but even though that makes the data available, we were still not using the discounted price in the variant selector. This PR also modifies the logic for displaying the price in the selector to take the discount into account.

Screen Shot 2020-06-10 at 2 16 24 PM

Fixes #43122

Testing instructions

  • Use a site which already has a plan (eg: Personal).
  • Add a higher-priced plan to the cart (eg: Premium).
  • Visit composite checkout.
  • Click the "Edit" button for the review step (the first step at the top of checkout).
  • Verify that the discounted price for the plan in the cart matches the price in the one-and-two-year variant selector.

@matticbot
Copy link
Contributor

@sirbrillig sirbrillig self-assigned this Jun 9, 2020
@matticbot
Copy link
Contributor

matticbot commented Jun 9, 2020

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

Sections (~39 bytes added 📈 [gzipped])

name      parsed_size           gzip_size
checkout       +259 B  (+0.0%)      +39 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 (~8 bytes added 📈 [gzipped])

name                      parsed_size           gzip_size
async-load-design-blocks        +34 B  (+0.0%)       +8 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.

@sirbrillig sirbrillig changed the title composite-checkout: Move Query components to render output composite-checkout: Fix discounted price in variant picker Jun 10, 2020
@sirbrillig
Copy link
Member Author

Just need to make sure this works with monthly prices and bi-annual prices. There's some additional logic in SubscriptionLengthPicker that we might need.

@sirbrillig sirbrillig added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Feature] Checkout The checkout screen and process for purchases made on WordPress.com. labels Jun 10, 2020
@sirbrillig sirbrillig marked this pull request as ready for review June 10, 2020 18:23
Copy link
Contributor

@fditrapani fditrapani left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together. It's good to see the prices properly reflected there. Looking at it though, I'm not sure why I'm getting the discount. Maybe we need to add a descriptor under savings to match what we're doing with coupons (I used similar copy from our plans page but am open to suggestions):

image

I also noticed if I press the delete button next to total savings, it doesn't do anything. We should probably only show that if a coupon has been applied.

@sirbrillig
Copy link
Member Author

@fditrapani thanks! Since neither of those requests have much to do with the variant picker that's fixed by this PR I made them into their own issues that I'll tackle separately: #43167 and #43168

@sirbrillig sirbrillig force-pushed the fix/composite-checkout-variant-discount-price branch from 8656213 to 3ba026b Compare June 11, 2020 00:17
@fditrapani
Copy link
Contributor

Awesome. thank you!

@sirbrillig sirbrillig force-pushed the fix/composite-checkout-variant-discount-price branch from 3ba026b to 0b5a275 Compare June 11, 2020 16:24
@sirbrillig sirbrillig force-pushed the fix/composite-checkout-variant-discount-price branch from 0b5a275 to 5f1c27f Compare June 11, 2020 17:39
@sirbrillig sirbrillig merged commit 0665203 into master Jun 11, 2020
@sirbrillig sirbrillig deleted the fix/composite-checkout-variant-discount-price branch June 11, 2020 22:25
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Checkout The checkout screen and process for purchases made on WordPress.com.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checkout: Plan variation picker not displaying pro-rated discount (4)
3 participants