I have two different payment gateway (stripe and bank transfer) in Woocommerce checkout page. But "Bank transfer" (bacs) is always auto selected by default.
Here is screenshot of the payment gateways on my checkout page:
I would like to change that and auto select stripe payment gateway intead.
How can I do it?. Any help is appreciated.
Updated
You can try to add the following code, to change the default payment gateway on checkout page. You will have to define the default desired payment gateway ID, in this code:
add_action( 'template_redirect', 'define_default_payment_gateway' );
function define_default_payment_gateway(){
if( is_checkout() && ! is_wc_endpoint_url() ) {
// HERE define the default payment gateway ID
$default_payment_id = 'stripe';
WC()->session->set( 'chosen_payment_method', $default_payment_id );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
You will always get Stripe as default now:
To get the needed payment gateway ID for Stripe , go in Woocommerce > Settings > Checkout and find it in the "Gateway ID" column as in this screenshot:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With