Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally display payment methods (4077) #3021

Merged
merged 9 commits into from
Jan 24, 2025
Prev Previous commit
Next Next commit
Add display conditions for applepay, googleplay and fastlane
Dinamiko committed Jan 24, 2025
commit 8cba869d7c90a71d203e68b943e6b14ee910bee9
9 changes: 9 additions & 0 deletions modules/ppcp-settings/src/SettingsModule.php
Original file line number Diff line number Diff line change
@@ -278,22 +278,31 @@ function( array $payment_methods ) use ( $container ) : array {
$applepay_product_status = $container->get( 'applepay.apple-product-status' );
assert( $applepay_product_status instanceof AppleProductStatus );

// Unset BCDC if merchant is eligible for ACDC.
if ( $dcc_product_status->dcc_is_active() ) {
unset( $payment_methods['ppcp-card-button-gateway'] );
}

// Unset Venmo when store location is not United States.
if ( $container->get( 'api.shop.country' ) !== 'US' ) {
unset( $payment_methods['venmo'] );
}

// Unset if not eligible for Google Pay.
if ( ! $googlepay_product_status->is_active() ) {
unset( $payment_methods['ppcp-googlepay'] );
}

// Unset if not eligible for Apple Pay.
if ( ! $applepay_product_status->is_active() ) {
unset( $payment_methods['ppcp-applepay'] );
}

// Unset Fastlane if store location is not United States or merchant is not eligible for ACDC.
if ( $container->get( 'api.shop.country' ) !== 'US' || ! $dcc_product_status->dcc_is_active() ) {
unset( $payment_methods['ppcp-axo-gateway'] );
}

return $payment_methods;
}
);