Skip to content

Instantly share code, notes, and snippets.

@jondcampbell
Created April 10, 2018 22:55
Show Gist options
  • Save jondcampbell/3a173d655d56f72706a751c20db91810 to your computer and use it in GitHub Desktop.
Save jondcampbell/3a173d655d56f72706a751c20db91810 to your computer and use it in GitHub Desktop.
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
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment