🐛 Hide disabled APM buttons in Standard Payments

This commit is contained in:
Philipp Stracker 2024-06-12 15:45:54 +02:00
parent 874ebbc7a0
commit f3f6765ac3
No known key found for this signature in database
3 changed files with 10 additions and 0 deletions

View file

@ -250,11 +250,13 @@ class DataToAppleButtonScripts {
$lang = $this->settings->has( 'applepay_button_language' ) ? $this->settings->get( 'applepay_button_language' ) : ''; $lang = $this->settings->has( 'applepay_button_language' ) ? $this->settings->get( 'applepay_button_language' ) : '';
$lang = apply_filters( 'woocommerce_paypal_payments_applepay_button_language', $lang ); $lang = apply_filters( 'woocommerce_paypal_payments_applepay_button_language', $lang );
$checkout_data_mode = $this->settings->has( 'applepay_checkout_data_mode' ) ? $this->settings->get( 'applepay_checkout_data_mode' ) : PropertiesDictionary::BILLING_DATA_MODE_DEFAULT; $checkout_data_mode = $this->settings->has( 'applepay_checkout_data_mode' ) ? $this->settings->get( 'applepay_checkout_data_mode' ) : PropertiesDictionary::BILLING_DATA_MODE_DEFAULT;
$is_enabled = $this->settings->has( 'applepay_button_enabled' ) && $this->settings->get( 'applepay_button_enabled' );
return array( return array(
'sdk_url' => $this->sdk_url, 'sdk_url' => $this->sdk_url,
'is_debug' => defined( 'WP_DEBUG' ) && WP_DEBUG ? true : false, 'is_debug' => defined( 'WP_DEBUG' ) && WP_DEBUG ? true : false,
'is_admin' => true, 'is_admin' => true,
'is_enabled' => $is_enabled,
'preferences' => array( 'preferences' => array(
'checkout_data_mode' => $checkout_data_mode, 'checkout_data_mode' => $checkout_data_mode,
), ),

View file

@ -94,6 +94,11 @@ class PreviewButton {
* Will always create a new button in the DOM. * Will always create a new button in the DOM.
*/ */
render() { render() {
// The APM button is disabled and cannot be enabled on the current page: Do not render it.
if (!this.isDynamic && !this.buttonConfig.is_enabled) {
return;
}
if (!this.domWrapper) { if (!this.domWrapper) {
if (!this.wrapper) { if (!this.wrapper) {
console.error('Skip render, button is not configured yet'); console.error('Skip render, button is not configured yet');

View file

@ -418,9 +418,12 @@ class Button implements ButtonInterface {
$shipping['countries'] = array_keys( $this->wc_countries()->get_shipping_countries() ); $shipping['countries'] = array_keys( $this->wc_countries()->get_shipping_countries() );
} }
$is_enabled = $this->settings->has( 'googlepay_button_enabled' ) && $this->settings->get( 'googlepay_button_enabled' );
return array( return array(
'environment' => $this->environment->current_environment_is( Environment::SANDBOX ) ? 'TEST' : 'PRODUCTION', 'environment' => $this->environment->current_environment_is( Environment::SANDBOX ) ? 'TEST' : 'PRODUCTION',
'is_debug' => defined( 'WP_DEBUG' ) && WP_DEBUG ? true : false, 'is_debug' => defined( 'WP_DEBUG' ) && WP_DEBUG ? true : false,
'is_enabled' => $is_enabled,
'sdk_url' => $this->sdk_url, 'sdk_url' => $this->sdk_url,
'button' => array( 'button' => array(
'wrapper' => '#ppc-button-googlepay-container', 'wrapper' => '#ppc-button-googlepay-container',