We've removed the payment information on our customer emails but can't remove the title. How do we do it?We're using Woocommerce email templates for order confirmation emails.
We've searched in and tried to change
We tried this one in email-order-details, it did not work at all.
<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>
To remove payment method from WooCommerce email notifications using hooks:
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;
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Or overriding email-order-details.php
template file:
<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>
It should also works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With