Home > Mobile >  Title WooCommerce gateway
Title WooCommerce gateway

Time:04-27

I try to modify the title of my payment gateways who are displayed in a tax receipt. But Don't find where to change this.

I have "BACS" that I want to --> virement bancaire I have "Monetico" that I want to --> CB

By'.$order->get_payment_method().'.

I can listen all answers.

Thanks in advance

CodePudding user response:

add_filter('woocommerce_order_get_payment_method_title', 'alter_payment_method_title', 10, 2);

function alter_payment_method_title($payment_method_title, $order) {

    if ('Direct Bank Transfer' === $payment_method_title) {
        $payment_method_title = 'virement bancaire';
    }
    if ('Monetico' === $payment_method_title) {
        $payment_method_title = 'CB';
    }
    if ('Cash on delivery' === $payment_method_title) {
        $payment_method_title = 'Cash on arrival';
    }
    return $payment_method_title;
}

Tested ok With WooCommerce 6.4

Add the above code to your active theme functions.php file

CodePudding user response:

Change Title add_filter( 'woocommerce_gateway_title', 'rudr_change_payment_gateway_title', 25, 2 );

function rudr_change_payment_gateway_title( $title, $gateway_id ){

if( 'cod' === $gateway_id ) {
    $title = 'By Cash or Credit Card on delivery';
}

return $title;

}

Change Description add_filter( 'woocommerce_gateway_description', 'rudr_change_payment_gateway_description', 25, 2 );

function rudr_change_payment_gateway_description( $description, $gateway_id ) {

if( 'cod' === $gateway_id ) {
    // you can use HTML tags here
    $description = 'Pay with cash upon delivery. Easy-breezy ;)';
}

return $description;

}

  • Related