Skip to content

Commit

Permalink
Hide credit card gateway on checkout when using Fastlane
Browse files Browse the repository at this point in the history
  • Loading branch information
Emili Castells Guasch authored and Emili Castells Guasch committed May 1, 2024
1 parent 912e0af commit 44d260e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions modules/ppcp-axo/src/AxoModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;

/**
* Class AxoModule
Expand Down Expand Up @@ -77,6 +78,31 @@ function ( $methods ) use ( $c ): array {
9
);

// Hides credit card gateway on checkout when using Fastlane.
add_filter(
'woocommerce_available_payment_gateways',
/**
* Param types removed to avoid third-party issues.
*
* @psalm-suppress MissingClosureParamType
*/
function ( $methods ) use ( $c ): array {
if ( ! is_array( $methods ) || ! $c->get( 'axo.eligible' ) ) {
return $methods;
}

if (
! is_admin()
&& is_user_logged_in() === false
&& isset( $methods[ CreditCardGateway::ID ] )
) {
unset( $methods[ CreditCardGateway::ID ] );
}

return $methods;
}
);

add_action(
'init',
static function () use ( $c, $module ) {
Expand Down

0 comments on commit 44d260e

Please sign in to comment.