Merge pull request #3566 from woocommerce/PCP-5021-new-ui-google-pay-dependencies-between-locations-for-payment-method-availability

Prevent early `is_enabled()` check for Google Pay button in new UI (5021)
This commit is contained in:
Niklas Gutberlet 2025-08-04 19:35:59 +02:00 committed by GitHub
commit ea1a9a0951
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
use WooCommerce\PayPalCommerce\Googlepay\Endpoint\UpdatePaymentDataEndpoint;
use WooCommerce\PayPalCommerce\Googlepay\Helper\ApmProductStatus;
use WooCommerce\PayPalCommerce\Googlepay\Helper\AvailabilityNotice;
use WooCommerce\PayPalCommerce\Settings\SettingsModule;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
@ -149,9 +150,11 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
add_action(
'woocommerce_blocks_payment_method_type_registration',
function( PaymentMethodRegistry $payment_method_registry ) use ( $c, $button ): void {
if ( $button->is_enabled() ) {
$payment_method_registry->register( $c->get( 'googlepay.blocks-payment-method' ) );
if ( SettingsModule::should_use_the_old_ui() && ! $button->is_enabled() ) {
return;
}
$payment_method_registry->register( $c->get( 'googlepay.blocks-payment-method' ) );
}
);