mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Merge pull request #3556 from woocommerce/PCP-4520-apple-pay-visible-on-chrome-and-fire-fox-as-payment-gateway-on-classic-checkout
Remove the specified gateway when the button is disabled (4520)
This commit is contained in:
commit
728ea64b0c
1 changed files with 18 additions and 16 deletions
|
@ -305,26 +305,28 @@ class StylingSettingsMapHelper {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $current_context === 'classic_checkout' ) {
|
||||
/**
|
||||
* Filters the available payment gateways to remove the specified gateway (e.g., Google Pay or Apple Pay)
|
||||
* when the button is disabled for the current location (e.g., classic checkout) in the styling settings.
|
||||
* This is necessary because WooCommerce automatically includes the gateway when it is enabled,
|
||||
* even if the button is hidden via settings.
|
||||
*/
|
||||
add_filter(
|
||||
'woocommerce_available_payment_gateways',
|
||||
/**
|
||||
* Outputs an inline CSS style that hides the Google Pay gateway (on Classic Checkout)
|
||||
* In case if the button is disabled from the styling settings but the gateway itself is enabled.
|
||||
* Param types removed to avoid third-party issues.
|
||||
*
|
||||
* @return void
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_checkout_button_render',
|
||||
static function (): void {
|
||||
?>
|
||||
<style data-hide-gateway='<?php echo esc_attr( GooglePayGateway::ID ); ?>'>
|
||||
.wc_payment_method.payment_method_ppcp-googlepay {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
static function ( $methods ) use ( $button_name, $current_context ): array {
|
||||
if ( $current_context !== 'classic_checkout' ) {
|
||||
return $methods;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
unset( $methods[ $button_name ] );
|
||||
return $methods;
|
||||
}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue