diff --git a/modules/ppcp-applepay/src/ApplepayModule.php b/modules/ppcp-applepay/src/ApplepayModule.php index 18b565544..470334c45 100644 --- a/modules/ppcp-applepay/src/ApplepayModule.php +++ b/modules/ppcp-applepay/src/ApplepayModule.php @@ -168,6 +168,20 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule } ); + add_filter( + 'woocommerce_paypal_payments_selected_button_locations', + function( array $locations, string $setting_name ) { + $gateway = WC()->payment_gateways()->payment_gateways()[ ApplePayGateway::ID ] ?? ''; + if ( $gateway && $gateway->enabled === 'yes' && $setting_name === 'smart_button_locations' ) { + $locations[] = 'checkout'; + } + + return $locations; + }, + 10, + 2 + ); + return true; } diff --git a/modules/ppcp-googlepay/src/GooglepayModule.php b/modules/ppcp-googlepay/src/GooglepayModule.php index 1b57a816a..6412f5c49 100644 --- a/modules/ppcp-googlepay/src/GooglepayModule.php +++ b/modules/ppcp-googlepay/src/GooglepayModule.php @@ -218,6 +218,20 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul } ); + add_filter( + 'woocommerce_paypal_payments_selected_button_locations', + function( array $locations, string $setting_name ) { + $gateway = WC()->payment_gateways()->payment_gateways()[ GooglePayGateway::ID ] ?? ''; + if ( $gateway && $gateway->enabled === 'yes' && $setting_name === 'smart_button_locations' ) { + $locations[] = 'checkout'; + } + + return $locations; + }, + 10, + 2 + ); + return true; } } diff --git a/modules/ppcp-wc-gateway/src/Helper/SettingsStatus.php b/modules/ppcp-wc-gateway/src/Helper/SettingsStatus.php index 502d7f1dc..b06c0b5e1 100644 --- a/modules/ppcp-wc-gateway/src/Helper/SettingsStatus.php +++ b/modules/ppcp-wc-gateway/src/Helper/SettingsStatus.php @@ -123,7 +123,11 @@ class SettingsStatus { protected function is_enabled_for_location( string $setting_name, string $location ): bool { $location = $this->normalize_location( $location ); - $selected_locations = $this->settings->has( $setting_name ) ? $this->settings->get( $setting_name ) : array(); + $selected_locations = apply_filters( + 'woocommerce_paypal_payments_selected_button_locations', + $this->settings->has( $setting_name ) ? $this->settings->get( $setting_name ) : array(), + $setting_name + ); if ( empty( $selected_locations ) ) { return false;