Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Update checkout payment methods design. #3439

Merged
merged 58 commits into from Feb 2, 2021

Conversation

budzanowski
Copy link
Contributor

@budzanowski budzanowski commented Nov 23, 2020

This PR implements the updated checkout payments UX.

Fixes #2628

Latest design available at pca54o-wS-p2 n90hX6hG3wwQbYwsYsrJnj-fi-4703%3A43711

Screenshots

image

image

How to test the changes in this Pull Request:

To test this one needs to use a combination of available and saved payment methods:

No saved payment methods.
One saved payment methods.
Multiple saved payment methods.

No payment methods.
One payment method.
Multiple saved payment methods.

The test should consist of checking the UI using combinations of saved and non-saved payment methods.
The other part of the test is ensuring that the payment methods still work.

Changelog

Update checkout block payment methods UI.

@budzanowski budzanowski requested a review from a team as a code owner November 23, 2020 06:12
@github-actions
Copy link
Contributor

github-actions bot commented Nov 23, 2020

Size Change: -23.1 kB (-2%)

Total Size: 1.16 MB

Filename Size Change
build/active-filters-frontend.js 8.32 kB -2 B (0%)
build/active-filters.js 8.49 kB +2 B (0%)
build/all-products-frontend.js 34.7 kB +6 B (0%)
build/all-products.js 36.2 kB +40 B (0%)
build/all-reviews.js 9.87 kB -8 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 3.36 kB -9 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 335 B -1 B (0%)
build/atomic-block-components/add-to-cart-frontend.js 9.23 kB +2 B (0%)
build/atomic-block-components/add-to-cart.js 7.7 kB +5 B (0%)
build/atomic-block-components/button-frontend.js 2.38 kB +1 B (0%)
build/atomic-block-components/button.js 839 B +2 B (0%)
build/atomic-block-components/image-frontend.js 1.77 kB +1 B (0%)
build/atomic-block-components/image.js 1.23 kB -1 B (0%)
build/atomic-block-components/price.js 1.85 kB -5 B (0%)
build/atomic-block-components/rating-frontend.js 522 B +1 B (0%)
build/atomic-block-components/sale-badge.js 866 B +4 B (0%)
build/atomic-block-components/sku-frontend.js 390 B +1 B (0%)
build/atomic-block-components/sku.js 394 B +1 B (0%)
build/atomic-block-components/stock-indicator-frontend.js 568 B -1 B (0%)
build/atomic-block-components/summary-frontend.js 917 B -1 B (0%)
build/atomic-block-components/summary.js 922 B -4 B (0%)
build/atomic-block-components/tag-list-frontend.js 466 B -1 B (0%)
build/atomic-block-components/tag-list.js 473 B +1 B (0%)
build/atomic-block-components/title-frontend.js 1.35 kB -1 B (0%)
build/atomic-block-components/title.js 1.21 kB -2 B (0%)
build/attribute-filter-frontend.js 18.2 kB +10 B (0%)
build/attribute-filter.js 12.5 kB +8 B (0%)
build/blocks-checkout.js 50.2 kB +16 B (0%)
build/blocks.js 3.49 kB +3 B (0%)
build/cart-frontend.js 63.6 kB +59 B (0%)
build/cart.js 34.2 kB +126 B (0%)
build/checkout-frontend.js 78.4 kB -10.9 kB (-12%) 👏
build/checkout.js 39.9 kB +98 B (0%)
build/handpicked-products.js 7.5 kB +5 B (0%)
build/price-filter.js 9.93 kB -4 B (0%)
build/product-best-sellers.js 7.57 kB +4 B (0%)
build/product-categories.js 3.24 kB +2 B (0%)
build/product-category.js 8.51 kB +7 B (0%)
build/product-new.js 7.74 kB +6 B (0%)
build/product-on-sale.js 8.12 kB -1 B (0%)
build/product-search.js 3.57 kB +11 B (0%)
build/product-tag.js 6.57 kB +5 B (0%)
build/product-top-rated.js 7.71 kB +5 B (0%)
build/products-by-attribute.js 8.49 kB +2 B (0%)
build/reviews-by-category.js 11.9 kB -3 B (0%)
build/reviews-by-product.js 13.5 kB -2 B (0%)
build/reviews-frontend.js 9.51 kB -5 B (0%)
build/single-product-frontend.js 37.9 kB +5 B (0%)
build/single-product.js 10.3 kB -9 B (0%)
build/style-rtl.css 18.9 kB +206 B (+1%)
build/style.css 18.8 kB +204 B (+1%)
build/vendors.js 418 kB -13 kB (-3%)
ℹ️ View Unchanged
Filename Size Change
build/atomic-block-components/category-list-frontend.js 469 B 0 B
build/atomic-block-components/category-list.js 476 B 0 B
build/atomic-block-components/price-frontend.js 1.83 kB 0 B
build/atomic-block-components/rating.js 525 B 0 B
build/atomic-block-components/sale-badge-frontend.js 859 B 0 B
build/atomic-block-components/stock-indicator.js 572 B 0 B
build/editor-rtl.css 14.9 kB 0 B
build/editor.css 14.9 kB 0 B
build/featured-category.js 7.81 kB 0 B
build/featured-product.js 10.1 kB 0 B
build/price-filter-frontend.js 14.5 kB 0 B
build/vendors--atomic-block-components/price-frontend.js 5.73 kB 0 B
build/vendors-style-rtl.css 1.05 kB 0 B
build/vendors-style.css 1.05 kB 0 B
build/wc-blocks-data.js 6.98 kB 0 B
build/wc-blocks-middleware.js 935 B 0 B
build/wc-blocks-registry.js 2.65 kB 0 B
build/wc-payment-method-bacs.js 820 B 0 B
build/wc-payment-method-cheque.js 816 B 0 B
build/wc-payment-method-cod.js 913 B 0 B
build/wc-payment-method-paypal.js 853 B 0 B
build/wc-payment-method-stripe.js 12.2 kB 0 B
build/wc-settings.js 2.4 kB 0 B
build/wc-shared-context.js 1.53 kB 0 B
build/wc-shared-hocs.js 1.68 kB 0 B

compressed-size-action

@haszari
Copy link
Member

haszari commented Nov 23, 2020

Gave this some early testing, this is looking good and working well – I really like the new radio button UI. I found a few gaps / tweaks, I'm guessing most of these are already on your radar.

  • Optimised / alternative simpler UI when there's one or two payment methods.
    • No saved cards, one method - show method UI inline, no selector needed.
    • No saved cards, two methods - show methods using tab UI (similar to current UI). 6b55b10
  • When the checkout loads there should be a payment method selected by default. In general, a payment method should always be selected. 5381cfc
    • Including if any payment methods disappear at runtime. This can happen with COD, which can be configured to only be available for specific shipping methods.
  • Full stop at end of payment method copy, e.g. Use another payment method.. 21d4532

I mostly tested in Safari and Firefox, with a range of payment methods, saved cards (or none) and window sizes (responsive modes seem to work ok). Tested saving payment methods to account, and as anon or logged-in user. Didn't see any payment issues, apart from being able to submit with no payment method selected 😄

Will need to do another test pass on the styling but it's all looking very much like the designs and working well 🚀

Copy link
Member

@haszari haszari left a comment

Choose a reason for hiding this comment

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

@budzanowski I did a quick investigation on why the defaulting isn't working - added clues in the comments. This isn't a full review, apologies for not helping more (yet!). I'll check back in tomorrow and push some fixes (if needed) 👍

);
const onChange = useCallback(
const [ savedMethodsToken, setSavedMethodsToken ] = useState( '' );
const [ paymentMethodsName, setPaymentMethodsName ] = useState( '' );
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you'll need state for these. The payment method context should handle all this (and provide it to the component). Take a look at how usePaymentMethodDataContext and usePaymentMethodInterface hooks are used in trunk to get and change the active payment method.

Copy link
Member

Choose a reason for hiding this comment

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

@budzanowski I ended up removing lots of this when I moved saved payment method token (saved card) state into context.

I don't think this caused problems, but there may be more tidying we can do here. There's some preexisting local state in SavedPaymentMethodOptions which I don't fully understand. We might be able to move that logic to context too, since the active payment method / token are closely related (i.e. same set of radio buttons).

id="wc-block-payment-methods"
<RadioControlAccordion
id={ 'wc-payment-method-options' }
selected={ selectedMethod }
Copy link
Member

Choose a reason for hiding this comment

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

You'll likely want to use activePaymentMethod here (ultimately powered by context - PaymentMethodDataContext).

That gives you the defaulting behaviour (ensure a payment method is selected at all times).

I hacked this change in my local dev and it fixes the missing default on load, and also handles if payment methods disappear at runtime (e.g. COD dependent on shipping).

Screen Capture on 2020-11-25 at 15-22-23

Copy link
Member

Choose a reason for hiding this comment

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

I've pushed a fix for this: 5381cfc

- using `activePaymentMethod` from context
- this ensures there is a default selected on initial render
- and handles any dynamic changes to available payment methods
  - e.g. COD disappearing when change shipping option
- remove unused / redundant selectedMethod prop - context is best
@budzanowski
Copy link
Contributor Author

The section labels weight was taken directly from the design doc:
image
Should this be followed up with the design?

@budzanowski
Copy link
Contributor Author

Payments label size fixed. Gosh, that was embarrassing. I did not have PayPal enabled the whole time 🤦🏻
image

Copy link
Contributor

@nerrad nerrad 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 addressing some of the feedback Bartek, testing seemed to go well.

Regarding section label weight: I see it matches designs, let's leave as is for now then.

There are still a few issues not addressed:

  • My comment about test coverage.
  • The regression in padding around the "Add a note to your order" checkbox.
  • The inconsistent spacing between payment method option text and the radio.

Screenshots for the last two issues:

In this PR:

Image 2021-01-29 at 7 47 21 AM

In trunk:

Image 2021-01-29 at 7 45 29 AM

Also, can you please verify you've:

  • tested accessibility of the ui.
  • tested with mobile views (seemed to work okay in my testing other than the order note checkbox issue which persists here).

@budzanowski
Copy link
Contributor Author

I have noticed that Chrome has an accessibility helper in inspect tool:
image
I am not sure how correct the tool is so I have tested manually how it works and IMO it works correctly.

Copy link
Contributor

@nerrad nerrad left a comment

Choose a reason for hiding this comment

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

Changes look good and test well. Designs in figma still have borders around the add notes checkbox:

Image 2021-02-01 at 11 15 23 AM

However, I'm fine with the current implementation - styles can be revisited in future work on things like the return to cart link and payment method button design mismatch.

@nerrad nerrad added type: enhancement The issue is a request for an enhancement. block: checkout Issues related to the checkout block. type: refactor The issue/PR is related to refactoring. and removed type: enhancement The issue is a request for an enhancement. labels Feb 1, 2021
@nerrad nerrad added this to the 4.5.0 milestone Feb 1, 2021
@budzanowski budzanowski merged commit 5f0c3fb into trunk Feb 2, 2021
@budzanowski budzanowski deleted the update/checkout-payment-methods-design branch February 2, 2021 04:51
@opr opr added the type: enhancement The issue is a request for an enhancement. label Feb 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: checkout Issues related to the checkout block. type: enhancement The issue is a request for an enhancement. type: refactor The issue/PR is related to refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checkout: update design of the payment methods
4 participants