简体   繁体   English

如何将付款方式从 WooCommerce 订单确认电子邮件更改为付款来源

[英]How to change payment method from WooCommerce order confirmation email to payment source

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.我们正在使用 Woocommerce Payments,在我们的订单确认电子邮件中,付款方式显示为 Woocommerce Payments,而不是诸如 Visa、Mastercard 等付款来源。

在此处输入图片说明

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
            }
        }
    }
?>

In your functions.php add this在你的functions.php中添加这个

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM