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

Uniform Smart Button Display for PayPal, Google Pay, and Apple Pay (2177) #1900

Conversation

pedrosilva-pt
Copy link
Contributor

This PR also resolves:
Do not render empty Apple Pay button div in frontend when buyer is not eligible (2411)

PR Description

This PR refactors Google Pay and Apple Pay so that they follow the PayPal button layout, namely button heights (responsive and fixed) and margins between buttons.

PayPal takes advantage of it's buttons being rendered inside an iframe to add responsive behaviour via media queries.

To emulate this behaviour and add responsiveness to Google Pay and Apple Pay this PR adds ApmButtons helper class.
The helper calculates button margins and adds CSS classes to the button containers to allow for responsiveness.

This PR also ensures that Apple Pay is only rendered on eligible devices.

It also adds apm-button.scss mixin to share CSS rules between modules (buttons, blocks, admin) and between APM buttons (googlepay, applepay).

Issue Description

As a website owner,
I want the PayPal, Google Pay, and Apple Pay smart buttons to have a consistent appearance,
So that my website provides a cohesive and visually appealing payment experience to users.

Acceptance Criteria:

1. PayPal Smart Button:

  • The width is already limited to 750px.
  • The PayPal button shape should apply to the other buttons
  • The PayPal button height should apply to the other buttons

2. Google Pay Smart Button:

  • The width should be limited to 750px.
  • The button height should be consistent with the PayPal buttons
  • margins above/below should match PayPal buttons

3. Apple Pay Smart Button:

  • The width should be limited to 750px.
  • The button height should be consistent with the PayPal buttons
  • margins above/below should match PayPal buttons
  • margins around the button should not be present when the button cannot be displayed (e.g. when not eligible)

add_action(
'wp_enqueue_scripts',
static function () use ( $c ) {
if ( ! has_block( 'woocommerce/checkout' ) && ! has_block( 'woocommerce/cart' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not load in editor (if block not added yet).

If we want to fix that, here is how I check it in the messaging branch 4e34332

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we should load in the block editor right now as the preview there currently isn't working, maybe address it in the context of that fix:
image

}

jQuery(wrapper).append(appleContainer);
jQuery(wrapper).append(appleContainer); // ToDo: this selector doesnt seem valid.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it seems to be doing nothing. <apple-pay-button> is already added because we set innerHTML above.

@InpsydeNiklas InpsydeNiklas added this to the 2.4.3 milestone Dec 12, 2023
@Dinamiko Dinamiko merged commit ea23d09 into trunk Dec 14, 2023
14 checks passed
@Dinamiko Dinamiko deleted the PCP-2177-uniform-smart-button-display-for-pay-pal-google-pay-and-apple-pay branch December 14, 2023 08:56
@Dinamiko Dinamiko mentioned this pull request Dec 18, 2023
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