// Add this code to your Alidropship plugin's checkout page template file, e.g. checkout.php
// Move Stripe as the first payment option
add_action( 'woocommerce_checkout_order_review', 'move_stripe_payment_gateway_first', 10 );
function move_stripe_payment_gateway_first() {
// Check if WooCommerce is active
if ( class_exists( 'WooCommerce' ) ) {
// Get the WooCommerce payment gateways
$gateways = WC()->payment_gateways->get_available_payment_gateways();
if ( isset( $gateways['stripe'] ) ) {
$stripe_gateway = $gateways['stripe'];
unset( $gateways['stripe'] );
// Add the Stripe gateway back as the first option
$gateways = array_merge( array( 'stripe' => $stripe_gateway ), $gateways );
}
}
}
// Move PayPal as the second payment option
add_filter( 'woocommerce_gateway_order', 'move_paypal_payment_gateway_second', 10, 2 );
function move_paypal_payment_gateway_second( $gateways ) {
// Check if WooCommerce is active
if ( class_exists( 'WooCommerce' ) ) {
if ( isset( $gateways['paypal'] ) ) {
$paypal_gateway = $gateways['paypal'];
unset( $gateways['paypal'] );
// Add the PayPal gateway back as the second option
$gateways = array_merge( $gateways, array( 'paypal' => $paypal_gateway ) );
}
}
return $gateways;
}