block
1 month ago
plain
1 month ago
admin-cancelled-order.php
1 year ago
admin-failed-order.php
6 months ago
admin-new-order.php
6 months ago
admin-payment-gateway-enabled.php
2 months ago
customer-cancelled-order.php
6 months ago
customer-completed-order.php
6 months ago
customer-failed-order.php
6 months ago
customer-fulfillment-created.php
6 months ago
customer-fulfillment-deleted.php
6 months ago
customer-fulfillment-updated.php
1 month ago
customer-invoice.php
6 months ago
customer-new-account.php
6 months ago
customer-note.php
6 months ago
customer-on-hold-order.php
6 months ago
customer-pos-completed-order.php
6 months ago
customer-pos-refunded-order.php
6 months ago
customer-processing-order.php
6 months ago
customer-refunded-order.php
6 months ago
customer-reset-password.php
6 months ago
customer-stock-notification-verified.php
9 months ago
customer-stock-notification-verify.php
9 months ago
customer-stock-notification.php
9 months ago
email-addresses.php
3 months ago
email-customer-details.php
1 year ago
email-downloads.php
6 months ago
email-footer.php
6 months ago
email-fulfillment-details.php
2 months ago
email-fulfillment-items.php
1 month ago
email-header.php
2 months ago
email-mobile-messaging.php
2 years ago
email-order-details.php
1 month ago
email-order-items.php
1 month ago
email-styles.php
1 month ago
email-order-items.php
239 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Email Order Items |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-items.php. |
| 6 | * |
| 7 | * HOWEVER, on occasion WooCommerce will need to update template files and you |
| 8 | * (the theme developer) will need to copy the new files to your theme to |
| 9 | * maintain compatibility. We try to do this as little as possible, but it does |
| 10 | * happen. When this occurs the version of the template file will be bumped and |
| 11 | * the readme will list any important changes. |
| 12 | * |
| 13 | * @see https://woocommerce.com/document/template-structure/ |
| 14 | * @package WooCommerce\Templates\Emails |
| 15 | * @version 10.8.0 |
| 16 | */ |
| 17 | |
| 18 | use Automattic\WooCommerce\Utilities\FeaturesUtil; |
| 19 | |
| 20 | defined( 'ABSPATH' ) || exit; |
| 21 | |
| 22 | $margin_side = is_rtl() ? 'left' : 'right'; |
| 23 | |
| 24 | $email_improvements_enabled = FeaturesUtil::feature_is_enabled( 'email_improvements' ); |
| 25 | $price_text_align = $email_improvements_enabled ? 'right' : 'left'; |
| 26 | $block_email_editor_enabled = FeaturesUtil::feature_is_enabled( 'block_email_editor' ); |
| 27 | |
| 28 | foreach ( $items as $item_id => $item ) : |
| 29 | $product = $item->get_product(); |
| 30 | $sku = ''; |
| 31 | $purchase_note = ''; |
| 32 | $image = ''; |
| 33 | |
| 34 | if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { |
| 35 | continue; |
| 36 | } |
| 37 | |
| 38 | if ( is_object( $product ) ) { |
| 39 | $sku = $product->get_sku(); |
| 40 | $purchase_note = $product->get_purchase_note(); |
| 41 | $image = $product->get_image( $image_size ); |
| 42 | } |
| 43 | |
| 44 | ?> |
| 45 | <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>"> |
| 46 | <td class="td font-family text-align-left" style="vertical-align: <?php echo $block_email_editor_enabled ? 'top' : 'middle'; ?>; word-wrap:break-word;"> |
| 47 | <?php if ( $email_improvements_enabled ) { ?> |
| 48 | <table class="order-item-data" role="presentation"> |
| 49 | <tr> |
| 50 | <?php |
| 51 | // Show title/image etc. |
| 52 | if ( $show_image ) { |
| 53 | /** |
| 54 | * Email Order Item Thumbnail hook. |
| 55 | * |
| 56 | * @param string $image The image HTML. |
| 57 | * @param WC_Order_Item_Product $item The item being displayed. |
| 58 | * @since 2.1.0 |
| 59 | */ |
| 60 | echo '<td style="vertical-align: top;">' . wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', $image, $item ) ) . '</td>'; |
| 61 | } |
| 62 | ?> |
| 63 | <td> |
| 64 | <?php |
| 65 | /** |
| 66 | * Order Item Name hook. |
| 67 | * |
| 68 | * @param string $item_name The item name HTML. |
| 69 | * @param WC_Order_Item_Product $item The item being displayed. |
| 70 | * @since 2.1.0 |
| 71 | */ |
| 72 | $order_item_name = apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); |
| 73 | echo wp_kses_post( "<h3 style='font-size: inherit;font-weight: inherit;'>{$order_item_name}</h3>" ); |
| 74 | |
| 75 | // SKU. |
| 76 | if ( $show_sku && $sku ) { |
| 77 | echo wp_kses_post( ' (#' . $sku . ')' ); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Allow other plugins to add additional product information. |
| 82 | * |
| 83 | * @param int $item_id The item ID. |
| 84 | * @param WC_Order_Item_Product $item The item object. |
| 85 | * @param WC_Order $order The order object. |
| 86 | * @param bool $plain_text Whether the email is plain text or not. |
| 87 | * @since 2.3.0 |
| 88 | */ |
| 89 | do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text ); |
| 90 | |
| 91 | $item_meta = wc_display_item_meta( |
| 92 | $item, |
| 93 | array( |
| 94 | 'before' => '', |
| 95 | 'after' => '', |
| 96 | 'separator' => '<br>', |
| 97 | 'echo' => false, |
| 98 | 'label_before' => '<span>', |
| 99 | 'label_after' => ':</span> ', |
| 100 | ) |
| 101 | ); |
| 102 | echo '<div class="email-order-item-meta">'; |
| 103 | // Using wp_kses instead of wp_kses_post to remove all block elements. |
| 104 | echo wp_kses( |
| 105 | $item_meta, |
| 106 | array( |
| 107 | 'br' => array(), |
| 108 | 'span' => array(), |
| 109 | 'a' => array( |
| 110 | 'href' => true, |
| 111 | 'target' => true, |
| 112 | 'rel' => true, |
| 113 | 'title' => true, |
| 114 | ), |
| 115 | ) |
| 116 | ); |
| 117 | echo '</div>'; |
| 118 | |
| 119 | /** |
| 120 | * Allow other plugins to add additional product information. |
| 121 | * |
| 122 | * @param int $item_id The item ID. |
| 123 | * @param WC_Order_Item_Product $item The item object. |
| 124 | * @param WC_Order $order The order object. |
| 125 | * @param bool $plain_text Whether the email is plain text or not. |
| 126 | * @since 2.3.0 |
| 127 | */ |
| 128 | do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text ); |
| 129 | |
| 130 | ?> |
| 131 | </td> |
| 132 | </tr> |
| 133 | </table> |
| 134 | <?php |
| 135 | } else { |
| 136 | |
| 137 | // Show title/image etc. |
| 138 | if ( $show_image ) { |
| 139 | /** |
| 140 | * Email Order Item Thumbnail hook. |
| 141 | * |
| 142 | * @param string $image The image HTML. |
| 143 | * @param WC_Order_Item_Product $item The item being displayed. |
| 144 | * @since 2.1.0 |
| 145 | */ |
| 146 | echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', $image, $item ) ); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Order Item Name hook. |
| 151 | * |
| 152 | * @param string $item_name The item name HTML. |
| 153 | * @param WC_Order_Item_Product $item The item being displayed. |
| 154 | * @since 2.1.0 |
| 155 | */ |
| 156 | echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ); |
| 157 | |
| 158 | // SKU. |
| 159 | if ( $show_sku && $sku ) { |
| 160 | echo wp_kses_post( ' (#' . $sku . ')' ); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Allow other plugins to add additional product information. |
| 165 | * |
| 166 | * @param int $item_id The item ID. |
| 167 | * @param WC_Order_Item_Product $item The item object. |
| 168 | * @param WC_Order $order The order object. |
| 169 | * @param bool $plain_text Whether the email is plain text or not. |
| 170 | * @since 2.3.0 |
| 171 | */ |
| 172 | do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text ); |
| 173 | |
| 174 | wc_display_item_meta( |
| 175 | $item, |
| 176 | array( |
| 177 | 'label_before' => '<strong class="wc-item-meta-label" style="float: ' . ( is_rtl() ? 'right' : 'left' ) . '; margin-' . esc_attr( $margin_side ) . ': .25em; clear: both">', |
| 178 | ) |
| 179 | ); |
| 180 | |
| 181 | /** |
| 182 | * Allow other plugins to add additional product information. |
| 183 | * |
| 184 | * @param int $item_id The item ID. |
| 185 | * @param WC_Order_Item_Product $item The item object. |
| 186 | * @param WC_Order $order The order object. |
| 187 | * @param bool $plain_text Whether the email is plain text or not. |
| 188 | * @since 2.3.0 |
| 189 | */ |
| 190 | do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text ); |
| 191 | } |
| 192 | ?> |
| 193 | </td> |
| 194 | <td class="td font-family text-align-<?php echo esc_attr( $price_text_align ); ?>" style="vertical-align:middle;"> |
| 195 | <?php |
| 196 | $qty = $item->get_quantity(); |
| 197 | $refunded_qty = $order->get_qty_refunded_for_item( $item_id ); |
| 198 | |
| 199 | if ( $refunded_qty ) { |
| 200 | $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>'; |
| 201 | } else { |
| 202 | $qty_display = esc_html( $qty ); |
| 203 | } |
| 204 | /** |
| 205 | * Email Order Item Quantity hook. |
| 206 | * |
| 207 | * @since 2.4.0 |
| 208 | * @param string $qty_display Item quantity. |
| 209 | * @param WC_Order_Item_Product $item Item object. |
| 210 | * @return string |
| 211 | */ |
| 212 | $quantity = apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ); |
| 213 | if ( '' !== $quantity ) { |
| 214 | $quantity_prefix = $email_improvements_enabled ? '×' : ''; |
| 215 | echo wp_kses_post( $quantity_prefix . $quantity ); |
| 216 | } |
| 217 | ?> |
| 218 | </td> |
| 219 | <td class="td font-family text-align-<?php echo esc_attr( $price_text_align ); ?>" style="vertical-align:middle;"> |
| 220 | <?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?> |
| 221 | </td> |
| 222 | </tr> |
| 223 | <?php |
| 224 | |
| 225 | if ( $show_purchase_note && $purchase_note ) { |
| 226 | ?> |
| 227 | <tr> |
| 228 | <td colspan="3" class="font-family text-align-left" style="vertical-align:middle;"> |
| 229 | <?php |
| 230 | echo wp_kses_post( wpautop( do_shortcode( $purchase_note ) ) ); |
| 231 | ?> |
| 232 | </td> |
| 233 | </tr> |
| 234 | <?php |
| 235 | } |
| 236 | ?> |
| 237 | |
| 238 | <?php endforeach; ?> |
| 239 |