How to sort payment options at checkout - Alidropship original plugin

codergodcrypto

New Member
Hello,
We would like to move Stripe payment option as the first payment option on checkout before PayPal on Alidropship plugin.

Is there a snippet code we can use to make Stripe first and Paypal the second payment option on checkout?
 

chris37

Well-Known Member
Hello,
We would like to move Stripe payment option as the first payment option on checkout before PayPal on Alidropship plugin.

Is there a snippet code we can use to make Stripe first and Paypal the second payment option on checkout?
Unfortunately is not any snippet code for that, you use the original plugin and theme so you must wait for the alidropship plugin developer to allow this option in the next update if they agree to do it. If you had woocommerce is a very easy switch that takes only a second.
 

armandobrown

New Member
Someone tried to do this using GPT? he generated me such code:
Code:
// 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;
}
Please note that the above code assumes that the payment gateway IDs for Stripe and PayPal in WooCommerce are 'stripe' and 'paypal' respectively. If your plugin is using different IDs for these gateways, you may need to update the code accordingly. By the way, I still wanted to tell you about a new site I found recently, https://casinosanalyzer.com/online-casinos/paypal I think many already know about it, but maybe you haven't heard about it and I wanted to tell you that here are gathered all the payment methods and apparently casino that exist to manage to put money where you wouldn't be. There are a wide variety there like PayPal and others.
 
Last edited:
Top