admin-cancelled-order.php
1 year ago
admin-failed-order.php
1 year ago
admin-new-order.php
11 months ago
admin-payment-gateway-enabled.php
2 months ago
customer-cancelled-order.php
11 months ago
customer-completed-order.php
1 year ago
customer-failed-order.php
1 year ago
customer-fulfillment-created.php
10 months ago
customer-fulfillment-deleted.php
10 months ago
customer-fulfillment-updated.php
1 month ago
customer-invoice.php
1 year ago
customer-new-account.php
11 months ago
customer-note.php
10 months ago
customer-on-hold-order.php
1 year ago
customer-pos-completed-order.php
11 months ago
customer-pos-refunded-order.php
11 months ago
customer-processing-order.php
1 year ago
customer-refunded-order.php
1 year ago
customer-reset-password.php
1 year ago
customer-review-request.php
3 weeks 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
2 years ago
email-customer-details.php
2 years ago
email-downloads.php
2 years ago
email-fulfillment-details.php
10 months ago
email-fulfillment-items.php
1 month ago
email-order-details.php
1 month ago
email-order-items.php
1 month ago
email-order-items.php
120 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Email Order Items (plain) |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/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\Plain |
| 15 | * @version 10.8.0 |
| 16 | */ |
| 17 | |
| 18 | use Automattic\WooCommerce\Utilities\FeaturesUtil; |
| 19 | |
| 20 | if ( ! defined( 'ABSPATH' ) ) { |
| 21 | exit; // Exit if accessed directly. |
| 22 | } |
| 23 | |
| 24 | $email_improvements_enabled = FeaturesUtil::feature_is_enabled( 'email_improvements' ); |
| 25 | |
| 26 | foreach ( $items as $item_id => $item ) : |
| 27 | if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { |
| 28 | $product = $item->get_product(); |
| 29 | $sku = ''; |
| 30 | $purchase_note = ''; |
| 31 | |
| 32 | if ( is_object( $product ) ) { |
| 33 | $sku = $product->get_sku(); |
| 34 | $purchase_note = $product->get_purchase_note(); |
| 35 | } |
| 36 | |
| 37 | if ( $email_improvements_enabled ) { |
| 38 | /** |
| 39 | * Email Order Item Name hook. |
| 40 | * |
| 41 | * @since 2.1.0 |
| 42 | * @since 2.4.0 Added $is_visible parameter. |
| 43 | * @param string $product_name Product name. |
| 44 | * @param WC_Order_Item $item Order item object. |
| 45 | * @param bool $is_visible Is item visible. |
| 46 | */ |
| 47 | $product_name = apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); |
| 48 | /** |
| 49 | * Email Order Item Quantity hook. |
| 50 | * |
| 51 | * @since 2.4.0 |
| 52 | * @param int $quantity Item quantity. |
| 53 | * @param WC_Order_Item $item Item object. |
| 54 | */ |
| 55 | $quantity = apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); |
| 56 | if ( '' !== $quantity ) { |
| 57 | $product_name .= ' × ' . $quantity; |
| 58 | } |
| 59 | echo wp_kses_post( str_pad( wp_kses_post( $product_name ), 40 ) ); |
| 60 | echo ' '; |
| 61 | echo esc_html( str_pad( wp_kses( $order->get_formatted_line_subtotal( $item ), array() ), 20, ' ', STR_PAD_LEFT ) ) . "\n"; |
| 62 | if ( $show_sku && $sku ) { |
| 63 | echo esc_html( '(#' . $sku . ")\n" ); |
| 64 | } |
| 65 | } else { |
| 66 | // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 67 | /** |
| 68 | * Email Order Item Name hook. |
| 69 | * |
| 70 | * @since 2.1.0 |
| 71 | * @since 2.4.0 Added $is_visible parameter. |
| 72 | * @param string $product_name Product name. |
| 73 | * @param WC_Order_Item $item Order item object. |
| 74 | * @param bool $is_visible Is item visible. |
| 75 | */ |
| 76 | echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ); |
| 77 | if ( $show_sku && $sku ) { |
| 78 | echo ' (#' . $sku . ')'; |
| 79 | } |
| 80 | /** |
| 81 | * Email Order Item Quantity hook. |
| 82 | * |
| 83 | * @since 2.4.0 |
| 84 | * @param int $quantity Item quantity. |
| 85 | * @param WC_Order_Item $item Item object. |
| 86 | */ |
| 87 | $quantity = apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); |
| 88 | if ( '' !== $quantity ) { |
| 89 | echo ' × ' . $quantity; |
| 90 | } |
| 91 | echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n"; |
| 92 | // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 93 | } |
| 94 | |
| 95 | // allow other plugins to add additional product information here. |
| 96 | do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text ); |
| 97 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 98 | echo strip_tags( |
| 99 | wc_display_item_meta( |
| 100 | $item, |
| 101 | array( |
| 102 | 'before' => "\n- ", |
| 103 | 'separator' => "\n- ", |
| 104 | 'after' => '', |
| 105 | 'echo' => false, |
| 106 | 'autop' => false, |
| 107 | ) |
| 108 | ) |
| 109 | ); |
| 110 | |
| 111 | // allow other plugins to add additional product information here. |
| 112 | do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text ); |
| 113 | } |
| 114 | // Note. |
| 115 | if ( $show_purchase_note && $purchase_note ) { |
| 116 | echo "\n" . do_shortcode( wp_kses_post( $purchase_note ) ); |
| 117 | } |
| 118 | echo "\n\n"; |
| 119 | endforeach; |
| 120 |