![](/img/trans.png)
[英]How to change payment method from WooCommerce order confirmation email to payment source
[英]How to remove payment method from WooCommerce order confirmation email?
我們已刪除客戶電子郵件中的付款信息,但無法刪除標題。 我們怎么做?我們使用 Woocommerce email 模板來發送訂單確認電子郵件。
我們已經搜索並試圖改變
我們在電子郵件訂單詳細信息中嘗試了這個,它根本不起作用。
<tfoot>
<?php
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
if ( $total['label'] != '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
}
}
}
?>
</tfoot>
要使用掛鈎從 WooCommerce email 通知中刪除付款方式:
add_filter( 'woocommerce_get_order_item_totals', 'remove_paymeny_method_row_from_emails', 10, 3 );
function remove_paymeny_method_row_from_emails( $total_rows, $order, $tax_display ){
// On Email notifications only
if ( ! is_wc_endpoint_url() ) {
unset($total_rows['payment_method']);
}
return $total_rows;
}
代碼進入活動子主題(或活動主題)的functions.php文件。 測試和工作。
或覆蓋email-order-details.php
模板文件:
<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
}
}
}
?>
</tfoot>
它也應該有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.