Enforce Fastlane to be the first payment method

This commit is contained in:
Philipp Stracker 2024-09-12 16:38:27 +02:00
parent 9a132fc050
commit 0cdfe13102
No known key found for this signature in database

View file

@ -28,6 +28,8 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector;
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsListener;
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
use WC_Payment_Gateways;
/**
* Class AxoModule
*/
@ -130,6 +132,20 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule {
}
);
// Enforce Fastlane to always be the first payment method in the list.
add_action(
'wc_payment_gateways_initialized',
function ( WC_Payment_Gateways $gateways ) {
foreach ( $gateways->payment_gateways as $key => $gateway ) {
if ( $gateway->id === AxoGateway::ID ) {
unset( $gateways->payment_gateways[ $key ] );
array_unshift( $gateways->payment_gateways, $gateway );
break;
}
}
}
);
// Force 'cart-block' and 'cart' Smart Button locations in the settings.
add_action(
'admin_init',