暫無描述

email-order-items.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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://docs.woocommerce.com/document/template-structure/
  14. * @package WooCommerce\Templates\Emails\Plain
  15. * @version 5.2.0
  16. */
  17. if ( ! defined( 'ABSPATH' ) ) {
  18. exit; // Exit if accessed directly.
  19. }
  20. foreach ( $items as $item_id => $item ) :
  21. if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
  22. $product = $item->get_product();
  23. $sku = '';
  24. $purchase_note = '';
  25. if ( is_object( $product ) ) {
  26. $sku = $product->get_sku();
  27. $purchase_note = $product->get_purchase_note();
  28. }
  29. // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
  30. echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) );
  31. if ( $show_sku && $sku ) {
  32. echo ' (#' . $sku . ')';
  33. }
  34. echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item );
  35. echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n";
  36. // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
  37. // allow other plugins to add additional product information here.
  38. do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
  39. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  40. echo strip_tags(
  41. wc_display_item_meta(
  42. $item,
  43. array(
  44. 'before' => "\n- ",
  45. 'separator' => "\n- ",
  46. 'after' => '',
  47. 'echo' => false,
  48. 'autop' => false,
  49. )
  50. )
  51. );
  52. // allow other plugins to add additional product information here.
  53. do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
  54. }
  55. // Note.
  56. if ( $show_purchase_note && $purchase_note ) {
  57. echo "\n" . do_shortcode( wp_kses_post( $purchase_note ) );
  58. }
  59. echo "\n\n";
  60. endforeach;