Advertisement
nshelper

Untitled

Sep 17th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.62 KB | None | 0 0
  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://docs.woocommerce.com/document/template-structure/
  14. * @package WooCommerce/Templates/Emails
  15. * @version 3.7.0
  16. */
  17.  
  18. /*
  19. * EDIT NOTES FOR KADENCE WOOMAIL DESIGNER
  20. *
  21. * ADDED: responsive mode so table is only two columns.
  22. */
  23.  
  24. defined( 'ABSPATH' ) || exit;
  25.  
  26. $text_align = is_rtl() ? 'right' : 'left';
  27. $margin_side = is_rtl() ? 'left' : 'right';
  28.  
  29. $responsive_check = Kadence_Woomail_Customizer::opt( 'responsive_mode' );
  30. if ( true == $responsive_check ) {
  31. foreach ( $items as $item_id => $item ) :
  32. do_action( 'woocommerce/cart_loop/start', $item );
  33. $product = $item->get_product();
  34. $sku = '';
  35. $purchase_note = '';
  36. $image = '';
  37.  
  38. if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
  39. do_action( 'woocommerce/cart_loop/end', $item );
  40. continue;
  41. }
  42.  
  43. if ( is_object( $product ) ) {
  44. $sku = $product->get_sku();
  45. $purchase_note = $product->get_purchase_note();
  46. $image = $product->get_image( $image_size );
  47. }
  48.  
  49. ?>
  50. <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
  51. <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align: middle; word-wrap:break-word;">
  52. <?php
  53.  
  54. // Show title/image etc.
  55. if ( $show_image ) {
  56. echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', $image, $item ) );
  57. }
  58.  
  59. // Product name.
  60. echo '<p style="margin-bottom:0;"><strong>' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</strong></p>';
  61.  
  62. // SKU.
  63. if ( $show_sku && $sku ) {
  64. echo wp_kses_post( ' (#' . $sku . ')' );
  65. }
  66.  
  67. // allow other plugins to add additional product information here.
  68. do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
  69.  
  70. $qty = $item->get_quantity();
  71. $refunded_qty = $order->get_qty_refunded_for_item( $item_id );
  72.  
  73. if ( $refunded_qty ) {
  74. $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
  75. } else {
  76. $qty_display = esc_html( $qty );
  77. }
  78. echo '<p class="inside-quantity" style="margin-bottom:0;">' . esc_html__( 'Quantity:', 'kadence-woocommerce-email-designer' ) . ' ' . wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ) ) . '</p>';
  79.  
  80. wc_display_item_meta(
  81. $item,
  82. array(
  83. 'label_before' => '<strong class="wc-item-meta-label" style="margin-' . esc_attr( $margin_side ) . ': .25em; clear: both">',
  84. )
  85. );
  86.  
  87. // allow other plugins to add additional product information here.
  88. do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
  89.  
  90. ?>
  91. </td>
  92. <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle;">
  93. <?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?>
  94. </td>
  95. </tr>
  96. <?php
  97.  
  98. if ( $show_purchase_note && $purchase_note ) {
  99. ?>
  100. <tr>
  101. <td colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle;">
  102. <?php
  103. echo wp_kses_post( wpautop( do_shortcode( $purchase_note ) ) );
  104. ?>
  105. </td>
  106. </tr>
  107. <?php
  108. }
  109. ?>
  110.  
  111. <?php
  112. do_action( 'woocommerce/cart_loop/end', $item );
  113. endforeach;
  114.  
  115. } else {
  116. foreach ( $items as $item_id => $item ) :
  117. $product = $item->get_product();
  118. $sku = '';
  119. $purchase_note = '';
  120. $image = '';
  121.  
  122. if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
  123. continue;
  124. }
  125.  
  126. if ( is_object( $product ) ) {
  127. $sku = $product->get_sku();
  128. $purchase_note = $product->get_purchase_note();
  129. $image = $product->get_image( $image_size );
  130. }
  131.  
  132. ?>
  133. <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
  134. <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align: middle; word-wrap:break-word;">
  135. <?php
  136.  
  137. // Show title/image etc.
  138. if ( $show_image ) {
  139. echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', $image, $item ) );
  140. }
  141.  
  142. // Product name.
  143. echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) );
  144.  
  145. // SKU.
  146. if ( $show_sku && $sku ) {
  147. echo wp_kses_post( ' (#' . $sku . ')' );
  148. }
  149.  
  150. // allow other plugins to add additional product information here.
  151. do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
  152.  
  153. wc_display_item_meta(
  154. $item,
  155. array(
  156. 'label_before' => '<strong class="wc-item-meta-label" style="float: ' . esc_attr( $text_align ) . '; margin-' . esc_attr( $margin_side ) . ': .25em; clear: both">',
  157. )
  158. );
  159.  
  160. // allow other plugins to add additional product information here.
  161. do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
  162.  
  163. ?>
  164. </td>
  165. <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle;">
  166. <?php
  167. $qty = $item->get_quantity();
  168. $refunded_qty = $order->get_qty_refunded_for_item( $item_id );
  169.  
  170. if ( $refunded_qty ) {
  171. $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
  172. } else {
  173. $qty_display = esc_html( $qty );
  174. }
  175. echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ) );
  176. ?>
  177. </td>
  178. <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle;">
  179. <?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?>
  180. </td>
  181. </tr>
  182. <?php
  183.  
  184. if ( $show_purchase_note && $purchase_note ) {
  185. ?>
  186. <tr>
  187. <td colspan="3" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle;">
  188. <?php
  189. echo wp_kses_post( wpautop( do_shortcode( $purchase_note ) ) );
  190. ?>
  191. </td>
  192. </tr>
  193. <?php
  194. }
  195. ?>
  196.  
  197. <?php
  198. endforeach;
  199. }
  200. ?>
  201.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement