Adding Moneris credit card type to woocommerce order emails
<?php
/*
* This would fit into yourtheme/woocommerce/emails/email-order-details.php and replace the existing loop of totals in there.
*/
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $key => $total ) {
$i++;
// Try to add the credit card type to the payment method
if ( 'payment_method' === $key && 'Credit Card' === $total['value'] ) {
$order_post_id = $order->get_order_number();
$card_type = get_post_meta( $order_post_id, '_wc_moneris_card_type', true );
if ( 'visa' === $card_type ) {
$card_type = 'Visa';
} elseif ( 'mc' === $card_type ) {
$card_type = 'MasterCard';
} elseif ( 'amex' === $card_type ) {
$card_type = 'American Express';
}
$total['value'] = $card_type;
}
?><tr>
<th class="td" scope="row" colspan="2" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td class="td" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
?>