woocommerce / woocommerce-paypal-payments

https://wordpress.org/plugins/woocommerce-paypal-payments/
GNU General Public License v2.0
61 stars 47 forks source link

Apple Pay & Google Pay buttons no longer visible in Standard Payments button previews after moving them to Advanced Card Processing tab (3179) #2325

Closed stracker-phil closed 3 weeks ago

stracker-phil commented 1 month ago

Problem

After moving Google Pay and Apple Pay settings to the "Advanced Card Processing" tab, the button preview was not available anymore - neither in the "Standard Payments" nor the "Advanced Card Processing" tab.

Background

  1. Advanced Card Processing: Did not render the preview because relevant JS files were not enqueued
  2. Standard Payments: Did not render the preview because it was tightly coupled to the presence of certain DOM elements (eg the presence of an "is-enabled" checkbox)

Solution

  1. Refactor preview button code to decouple it from DOM elements
  2. Enqueue relevant JS files in both tabs

Changes

Preview button logic

Overview of code changes

ppcp-button/.../PreviewButton.js

ppcp-button/.../PreviewButtonManager.js

Both boot-admin.js

ppcp-wc-gateway/services.php

Both extensions.php

gateway-settings.js

Screenshots

Fixed preview of the full button block, in the "Standard Payments" tab: sp-button-block-preview

New preview of the single payment button, in the "Advanced Card Processing" tab: acp-single-button-preview