skip to Main Content

We are using Woocommerce Payments and on our order confirmation email the payment method comes up as Woocommerce Payments instead of the payment source such as Visa, Mastercard etc.

enter image description here

I have found how to remove the Payment method altogether (see below), but how would I remove this and add back in Payment Source?

<tfoot>
<?php
    if ( $totals = $order->get_order_item_totals() ) {
        $i = 0;
        foreach ( $totals as $key => $total ) {
            $i++;
            if ( $key !== 'payment_method' ){
                ?><tr>
                    <th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
                    <td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
                </tr><?php
            }
        }
    }
?>

2

Answers


  1. In your functions.php add this

    add_filter( 'woocommerce_get_order_item_totals', 'change_payment_method_name_in_emails', 10, 3 );
    function change_payment_method_name_in_emails( $total_rows, $order, $tax_display ){
        // On Email notifications only
        if ( ! is_wc_endpoint_url() ) {
            if($total_rows['payment_method']['value'] === 'Woocommerce Payments'){
                $total_rows['payment_method']['value'] = 'Visa/Master';
            }
        }
        return $total_rows;
    }
    
    Login or Signup to reply.
  2. It seems that the order field _payment_method_title is used in emails, while '_payment_method is the one displayed in the admin panel. So one option would be to update this field:

    $order->update_meta_data('_payment_method_title', '(payment method');
    

    You could do this in an action when the order is created or marked paid.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search