Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Email Order Items
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-items.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates/Emails
* @version 3.7.0
*/
defined( 'ABSPATH' ) || exit;
foreach ( $items as $item_id => $item ) :
$product = $item->get_product();
$sku = '';
$purchase_note = '';
$image = '';
if (!apply_filters('woocommerce_order_item_visible', true, $item)) {
continue;
}
if (is_object($product)) {
$sku = $product->get_sku();
$purchase_note = $product->get_purchase_note();
$image = $product->get_image($image_size, array(
'class' => 'pc-fb-font',
'alt' => $item->get_name(),
'style' => 'border: 0; outline: 0; line-height: 100%; -ms-interpolation-mode: bicubic; display: block;',
));
}
?>
<tr>
<td style="padding: 20px 10px 20px 0; letter-spacing: -0.2px; line-height: 26px; font-family: 'Fira Sans', Helvetica, Arial, sans-serif; font-size: 16px; border-bottom: 1px solid #E5E5E5;" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
<tbody>
<tr>
<td valign="top" style="font-size: 0;">
<!--[if (gte mso 9)|(IE)]><table role="presentation" cellspacing="0" cellpadding="0" border="0" width="400"><tr><td width="120" valign="top"><![endif]-->
<div style="display: inline-block; max-width: 120px; vertical-align: top;">
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
<tbody>
<tr>
<td style="padding: 0 20px 0 0;" valign="top">
<?php
// Show title/image etc.
if ($show_image) {
echo wp_kses_post(apply_filters('woocommerce_order_item_thumbnail', $image, $item));
}
?>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if (gte mso 9)|(IE)]></td><td width="280" valign="top"><![endif]-->
<div style="display: inline-block; max-width: 280px; vertical-align: top;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td style="padding: 9px 0 0;" valign="top">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td class="pc-fb-font" style="font-family: 'Fira Sans', Helvetica, Arial, sans-serif; letter-spacing: -0.3px; line-height: 28px; font-weight: 500; font-size: 18px; color: #151515;" valign="top">
<?php
// Product name.
echo wp_kses_post(apply_filters('woocommerce_order_item_name', $item->get_name(), $item, false));
// SKU.
if ($show_sku && $sku) {
echo wp_kses_post('<br />(#' . $sku . ')');
}
?>
</td>
</tr>
<tr>
<td height="4" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="pc-fb-font" style="font-family: 'Fira Sans', Helvetica, Arial, sans-serif; letter-spacing: -0.2px; line-height: 24px; font-size: 16px; color: #9B9B9B;" valign="top">
<?php
// allow other plugins to add additional product information here.
do_action('woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text);
wc_display_item_meta(
$item,
array(
'before' => '<ul class="wc-item-meta" style="margin:0; padding-left:0; list-style-type:none;"><li>',
)
);
// allow other plugins to add additional product information here.
do_action('woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text);
?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if (gte mso 9)|(IE)]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</td>
<td class="pc-fb-font" style="padding: 29px 10px 20px 0; color: #9B9B9B; letter-spacing: -0.2px; line-height: 26px; font-family: 'Fira Sans', Helvetica, Arial, sans-serif; font-size: 16px; border-bottom: 1px solid #E5E5E5;" valign="top" align="right">
<?php
$qty = $item->get_quantity();
$refunded_qty = $order->get_qty_refunded_for_item($item_id);
if ($refunded_qty) {
$qty_display = '<del>' . esc_html($qty) . '</del> <ins>' . esc_html($qty - ( $refunded_qty * -1 )) . '</ins>';
} else {
$qty_display = esc_html($qty);
}
echo wp_kses_post(apply_filters('woocommerce_email_order_item_quantity', $qty_display, $item));
?>
</td>
<td class="pc-fb-font" style="padding: 29px 0 20px; letter-spacing: -0.2px; line-height: 26px; font-family: 'Fira Sans', Helvetica, Arial, sans-serif; font-size: 16px; border-bottom: 1px solid #E5E5E5; color: #151515;" valign="top" align="right">
<?php echo wp_kses_post($order->get_formatted_line_subtotal($item)); ?>
</td>
</tr>
<?php
if ($show_purchase_note && $purchase_note) {
?>
<tr>
<td style="padding: 20px 10px 20px 0; letter-spacing: -0.2px; line-height: 22px; font-family: 'Fira Sans', Helvetica, Arial, sans-serif; font-size: 12px; border-bottom: 1px solid #E5E5E5;" valign="top" colspan="3">
<?php
echo wp_kses_post(wpautop(do_shortcode($purchase_note)));
?>
</td>
</tr>
<?php
}
?>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.