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

Pass product, blocks cart, classic cart and checkout on get WooPay session #9138

Merged

Conversation

hsingyuc
Copy link
Contributor

@hsingyuc hsingyuc commented Jul 19, 2024

Fixes https://github.com/Automattic/woopay/issues/2804

Changes proposed in this Pull Request

This PR extends from the pass Blocks checkout appearance on init WooPay PR and use getAppearanceType to get element selectors from each page since a shopper doesn't always visit the checkout page before going to the WooPay checkout page.

EPIC https://github.com/Automattic/woopay/issues/2781
SPIKE here
PT here
Related WooPay PR

Screen.Recording.2024-07-19.at.10.49.35.AM.mov

Testing instructions

  • Test with the latest WooPay trunk
  • Go to WooPay admin -> WCPay Dev and enable WooPay global theme support feature flag
  • Update the merchant styles:
  1. Install and activate a theme that supports the site editor from admin -> appearance -> theme
  2. Update typography by visiting Theme -> Editor -> Styles
    OR
  3. Update merchant styles ( ex. background color, text color, border styles, etc ) without using theme that supports the site editor from wp-admin appearance

Test 1 ( The latest WooPayments version ):

  1. Test this PR with the latest WooPayments version that includes getAppearance on the merchant site
  2. Open dev tools
  3. As an existing WooPay shopper, go to the Blocks checkout page and initialize WooPay with the email field redirect
  4. Find the get_woopay_session request from dev tools and see appearance is passing with the request
  5. Should see WooPay support background color, color, and font family
  6. Test Return to cart -> Blocks checkout page -> WooPay button
  7. Should see WooPay support background color, color, and font family
  8. Test Checkout as guest and initialize WooPay as a new WooPay shopper with the email field redirect
  9. Should see WooPay support background color, color, and font family
  10. Test Return to cart -> Blocks checkout page
  11. As a new WooPay shopper, initialize WooPay with the WooPay button
  12. Should see WooPay support background color, color, and font family
  13. Repeat the above by initializing WooPay on the product page, Blocks cart page, Classic cart page, and Classic checkout page.

Test 2 ( An older WooPayments version ):

  1. Test an older version of WooPayments like 7.6.0 that doesn't have getAppearance on the merchant site for regression test
  2. Repeat above testing instructions

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@hsingyuc hsingyuc requested review from a team and alefesouza and removed request for a team July 19, 2024 14:53
@botwoo
Copy link
Collaborator

botwoo commented Jul 19, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 9138 or branch name add/pass-appearance-from-classic-product-and-cart-page in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: 298ecdf
  • Build time: 2024-07-23 21:58:13 UTC

Note: the build is updated when a new commit is pushed to this PR.

Copy link
Contributor

github-actions bot commented Jul 19, 2024

Size Change: +594 B (0%)

Total Size: 1.33 MB

Filename Size Change
release/woocommerce-payments/dist/blocks-checkout.js 61 kB -17 B (0%)
release/woocommerce-payments/dist/cart-block.js 16.1 kB +55 B (0%)
release/woocommerce-payments/dist/checkout.js 31.7 kB +80 B (0%)
release/woocommerce-payments/dist/express-checkout.js 13.9 kB +56 B (0%)
release/woocommerce-payments/dist/payment-request.js 13.5 kB +56 B (0%)
release/woocommerce-payments/dist/product-details.js 11.3 kB +51 B (0%)
release/woocommerce-payments/dist/settings.js 223 kB +109 B (0%)
release/woocommerce-payments/dist/tokenized-payment-request.js 14.3 kB +58 B (0%)
release/woocommerce-payments/dist/woopay-express-button.js 23.9 kB +146 B (+1%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.08 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.08 kB
release/woocommerce-payments/assets/css/success.css 173 B
release/woocommerce-payments/assets/css/success.rtl.css 173 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.08 kB
release/woocommerce-payments/dist/blocks-checkout.css 2.08 kB
release/woocommerce-payments/dist/bnpl-announcement-rtl.css 528 B
release/woocommerce-payments/dist/bnpl-announcement.css 529 B
release/woocommerce-payments/dist/bnpl-announcement.js 20.8 kB
release/woocommerce-payments/dist/cart.js 5.63 kB
release/woocommerce-payments/dist/checkout-rtl.css 600 B
release/woocommerce-payments/dist/checkout.css 600 B
release/woocommerce-payments/dist/express-checkout-rtl.css 235 B
release/woocommerce-payments/dist/express-checkout.css 235 B
release/woocommerce-payments/dist/index-rtl.css 39.1 kB
release/woocommerce-payments/dist/index.css 39 kB
release/woocommerce-payments/dist/index.js 296 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.08 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.41 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.5 kB
release/woocommerce-payments/dist/multi-currency.css 3.41 kB
release/woocommerce-payments/dist/multi-currency.js 55.5 kB
release/woocommerce-payments/dist/order-rtl.css 730 B
release/woocommerce-payments/dist/order.css 730 B
release/woocommerce-payments/dist/order.js 42.7 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.js 39.2 kB
release/woocommerce-payments/dist/payment-request-rtl.css 235 B
release/woocommerce-payments/dist/payment-request.css 235 B
release/woocommerce-payments/dist/plugins-page-rtl.css 386 B
release/woocommerce-payments/dist/plugins-page.css 386 B
release/woocommerce-payments/dist/plugins-page.js 20.1 kB
release/woocommerce-payments/dist/product-details-rtl.css 397 B
release/woocommerce-payments/dist/product-details.css 398 B
release/woocommerce-payments/dist/settings-rtl.css 11.2 kB
release/woocommerce-payments/dist/settings.css 11.1 kB
release/woocommerce-payments/dist/subscription-edit-page.js 703 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 730 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tokenized-payment-request-rtl.css 235 B
release/woocommerce-payments/dist/tokenized-payment-request.css 235 B
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 235 B
release/woocommerce-payments/dist/tos.js 21.8 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 6.01 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 235 B
release/woocommerce-payments/dist/woopay-express-button.css 235 B
release/woocommerce-payments/dist/woopay-rtl.css 4.5 kB
release/woocommerce-payments/dist/woopay.css 4.47 kB
release/woocommerce-payments/dist/woopay.js 70.9 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 625 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 814 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.46 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.02 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 625 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 626 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 392 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 584 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.css 215 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 721 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 412 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 520 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 159 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.36 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.6 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.36 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.04 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 294 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 408 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.59 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 301 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 746 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 574 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 414 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 543 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.78 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.84 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 545 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.7 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 507 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 358 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 428 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 782 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.09 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.26 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 391 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.04 kB

compressed-size-action

@hsingyuc
Copy link
Contributor Author

@nikkivias @pierorocca, I'd like to get your attention on the classic checkout styling. Is the below behavior what we want to support on WooPay?

For the classic checkout on UPE styles, we focus on getting the styles from the payment form instead of the body.

  • If I don't intentionally set the payment form background color the same as the body background color on classic checkout
  • Use a dark background for the site
  • The payment form background color on the classic checkout would be a light background color ( example as below )
  • Since we are reusing UPE styling, WooPay will use the payment form styling as merchant global styling
Screenshot 2024-07-19 at 11 12 37 AM Screenshot 2024-07-19 at 11 06 53 AM Screenshot 2024-07-19 at 11 13 16 AM

@pierorocca
Copy link
Contributor

pierorocca commented Jul 19, 2024

@hsingyuc I wonder if this is due to how the computed styles works and when they are re-computed? I'm going to guess that like me, you switched colors in the editor, and then the computed styles were off. According to @FangedParakeet in this Slack thread p1721251046334039-slack-CU6SYV31A the computed values are stored in transients. The values are currently only getting recalculated after the transient expires (24 hours -- but I don't think this is working properly) or when the theme is changed. I suspect we need a few more triggers to force a recompute.

@hsingyuc could this be impacting your testing?

Copy link
Member

@alefesouza alefesouza left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @hsingyuc!

@pierorocca
Copy link
Contributor

@hsingyuc could this be impacting your testing?

Was this resolved??

@hsingyuc
Copy link
Contributor Author

@hsingyuc I wonder if this is due to how the computed styles works and when they are re-computed? I'm going to guess that like me, you switched colors in the editor, and then the computed styles were off. According to @FangedParakeet in this Slack thread p1721251046334039-slack-CU6SYV31A the computed values are stored in transients. The values are currently only getting recalculated after the transient expires (24 hours -- but I don't think this is working properly) or when the theme is changed. I suspect we need a few more triggers to force a recompute.

This is how UPE styles prioritize getting the styles from the classic checkout page. They prioritize payment method section before body. It's not a bug and I'm only wondering if this is what we want for WooPay as well. cc @nikkivias

I think what we want from WooPay might be different since UPE styles look like they are specific to Stripe elements and not an entire site like WooPay.

@hsingyuc
Copy link
Contributor Author

@hsingyuc could this be impacting your testing?
Was this resolved??

@pierorocca It tests as expected by following/reusing UPE styles, but I don't think that's what we want for WooPay, so I'd like to double-check with you and @nikkivias. If that's not what we would like for WooPay to support Classic checkout styles, we can add new rules for WooPay and not use UPE styles.

@pierorocca
Copy link
Contributor

pierorocca commented Jul 23, 2024

Can we double check because on Classic if I set the background to Black, the UPE styling background is showing as Black, contrary to your screen capture above.

image

@pierorocca
Copy link
Contributor

pierorocca commented Jul 23, 2024

Sometimes (most times) the classic editor does not show the updated styling:
image

Until an admin refreshes their save changes, or a shopper on the front end triggers a recalculation of the styles, or the transient expires (24 hours)
image

@pierorocca
Copy link
Contributor

pierorocca commented Jul 23, 2024

They prioritize payment method section before body

@hsingyuc I agree with this since the payment method section background colors are going to be slightly different than the body of the checkout form. We want WooPay to look like the Store Checkout/Brand rather than looking like UPE. Good catch.

@hsingyuc
Copy link
Contributor Author

@hsingyuc I agree with this since the payment method section background colors are going to be slightly different than the body of the checkout form. We want WooPay to look like the Store Checkout/Brand rather than looking like UPE. Good catch.

Thank you for confirming! I'll address this issue in another PR.

@hsingyuc hsingyuc enabled auto-merge July 23, 2024 21:54
@hsingyuc hsingyuc added this pull request to the merge queue Jul 23, 2024
Merged via the queue into develop with commit 385a47c Jul 23, 2024
23 checks passed
@hsingyuc hsingyuc deleted the add/pass-appearance-from-classic-product-and-cart-page branch July 23, 2024 22:07
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.

4 participants