bonnix

Kadence Customizer Email email-order-details.php

May 12th, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.97 KB | None | 0 0
  1. <?php
  2. /**
  3. * Order details table shown in emails.
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.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: option to split up order heading.
  22. * Because woocommerce subscriptions and woocommerce core share the same file name (WHY!!!) this file is long with included logic for subscriptions.
  23. * ADDED: responsive mode so table is only two columns.
  24. */
  25.  
  26. defined( 'ABSPATH' ) || exit;
  27.  
  28. $text_align = is_rtl() ? 'right' : 'left';
  29. $responsive_check = Kadence_Woomail_Customizer::opt( 'responsive_mode' );
  30. $zebra_check = Kadence_Woomail_Customizer::opt( 'items_table_background_odd_color' );
  31. $note_check = Kadence_Woomail_Customizer::opt( 'notes_outside_table' );
  32.  
  33. if ( isset( $order_type ) && 'subscription' === $order_type && class_exists( 'WC_Subscriptions_Email' ) ) {
  34. do_action( 'woocommerce_email_before_subscription_table', $order, $sent_to_admin, $plain_text, $email );
  35. if ( 'cancelled_subscription' != $email->id ) {
  36. echo '<h3>';
  37.  
  38. $link_element_url = ( $sent_to_admin ) ? wcs_get_edit_post_link( wcs_get_objects_property( $order, 'id' ) ) : $order->get_view_order_url();
  39. // translators: $1-$3: opening and closing <a> tags $2: subscription's order number.
  40. printf( esc_html_x( 'Subscription %1$s#%2$s%3$s', 'Used in email notification', 'kadence-woocommerce-email-designer' ), '<a href="' . esc_url( $link_element_url ) . '">', esc_html( $order->get_order_number() ), '</a>' );
  41. echo '</h3>';
  42. }
  43. if ( true == $responsive_check ) {
  44. ?>
  45. <div class="email-spacing-wrap" style="margin-bottom: 40px;">
  46. <table class="td" cellspacing="0" cellpadding="6" width="100%" style="width: 100%;" border="1">
  47. <thead>
  48. <tr>
  49. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'kadence-woocommerce-email-designer' ); ?></th>
  50. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'kadence-woocommerce-email-designer' ); ?></th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <?php echo wp_kses_post( WC_Subscriptions_Email::email_order_items_table( $order, $order_items_table_args ) ); ?>
  55. <?php
  56. if ( empty( $zebra_check ) ) {
  57. ?>
  58. </tbody>
  59. <tfoot>
  60. <?php
  61. }
  62. $item_totals = $order->get_order_item_totals();
  63.  
  64. if ( $item_totals ) {
  65. $i = 0;
  66. foreach ( $item_totals as $total ) {
  67. $i++;
  68. ?>
  69. <tr>
  70. <th class="td tlabel-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" scope="row" colspan="1" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['label'] ); ?></th>
  71. <td class="td tvalue-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['value'] ); ?></td>
  72. </tr>
  73. <?php
  74. }
  75. }
  76. if ( empty( $zebra_check ) ) {
  77. ?>
  78. </tfoot>
  79. <?php
  80. } else {
  81. ?>
  82. </tbody>
  83. <?php
  84. }
  85. ?>
  86. </table>
  87. </div>
  88.  
  89. <?php
  90. } else {
  91. ?>
  92. <div class="email-spacing-wrap" style="margin-bottom: 40px;">
  93. <table class="td" cellspacing="0" cellpadding="6" width="100%" style="width: 100%;" border="1">
  94. <thead>
  95. <tr>
  96. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'kadence-woocommerce-email-designer' ); ?></th>
  97. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'kadence-woocommerce-email-designer' ); ?></th>
  98. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'kadence-woocommerce-email-designer' ); ?></th>
  99. </tr>
  100. </thead>
  101. <tbody>
  102. <?php echo wp_kses_post( WC_Subscriptions_Email::email_order_items_table( $order, $order_items_table_args ) ); ?>
  103. <?php
  104. if ( empty( $zebra_check ) ) {
  105. ?>
  106. </tbody>
  107. <tfoot>
  108. <?php
  109. }
  110. $item_totals = $order->get_order_item_totals();
  111.  
  112. if ( $item_totals ) {
  113. $i = 0;
  114. foreach ( $item_totals as $total ) {
  115. $i++;
  116. ?>
  117. <tr>
  118. <th class="td tlabel-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['label'] ); ?></th>
  119. <td class="td tvalue-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['value'] ); ?></td>
  120. </tr>
  121. <?php
  122. }
  123. }
  124. if ( empty( $zebra_check ) ) {
  125. ?>
  126. </tfoot>
  127. <?php
  128. } else {
  129. ?>
  130. </tbody>
  131. <?php
  132. }
  133. ?>
  134. </table>
  135. </div>
  136. <?php
  137. }
  138. do_action( 'woocommerce_email_after_subscription_table', $order, $sent_to_admin, $plain_text, $email );
  139.  
  140. } else {
  141.  
  142. do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email );
  143. ?>
  144. <div style="clear:both; height:1px;"></div>
  145. <?php
  146. $order_head_style = Kadence_Woomail_Customizer::opt( 'order_heading_style' );
  147. if ( empty( $order_head_style ) ) {
  148. $order_head_style = 'normal';
  149. }
  150. if ( 'split' == $order_head_style ) {
  151. ?>
  152. <h2>
  153. <?php
  154. echo __( 'Order Details', 'kadence-woocommerce-email-designer' );
  155. ?>
  156. </h2>
  157. <table class="order-info-split-table" cellspacing="0" cellpadding="0" width="100%" border="0">
  158. <tr>
  159. <td align="left" valign="middle">
  160. <h3 style="text-align: left;">
  161. <?php
  162. if ( $sent_to_admin ) {
  163. $before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
  164. $after = '</a>';
  165. } else {
  166. $before = '';
  167. $after = '';
  168. }
  169. /* translators: %s: Order ID. */
  170. echo wp_kses_post( $before . sprintf( __( 'Order number: %s', 'kadence-woocommerce-email-designer' ) . $after, $order->get_order_number() ) );
  171. ?>
  172. </h3>
  173. </td>
  174. <td align="right" valign="middle">
  175. <h3 style="text-align: right;">
  176. <?php
  177. echo wp_kses_post( sprintf( __( 'Order date:', 'kadence-woocommerce-email-designer' ) . ' <time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) );
  178. ?>
  179. </h3>
  180. </td>
  181. </tr>
  182. </table>
  183. <?php
  184. } else {
  185. ?>
  186. <h2>
  187. <?php
  188. if ( $sent_to_admin ) {
  189. $before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
  190. $after = '</a>';
  191. } else {
  192. $before = '';
  193. $after = '';
  194. }
  195. /* translators: %s: Order ID. */
  196. echo wp_kses_post( $before . sprintf( __( 'Order #%s', 'kadence-woocommerce-email-designer' ) . $after . ' (<time datetime="%s">%s</time>)', $order->get_order_number(), $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) );
  197. ?>
  198. </h2>
  199. <?php } ?>
  200.  
  201. <?php
  202. if ( true == $responsive_check ) {
  203. ?>
  204. <div class="email-spacing-wrap" style="margin-bottom: 40px;">
  205. <table class="td" cellspacing="0" cellpadding="6" width="100%" style="width: 100%;" border="1">
  206. <thead>
  207. <tr>
  208. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'kadence-woocommerce-email-designer' ); ?></th>
  209. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'kadence-woocommerce-email-designer' ); ?></th>
  210. </tr>
  211. </thead>
  212. <tbody>
  213. <?php
  214. echo wc_get_email_order_items( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  215. $order,
  216. array(
  217. 'show_sku' => $sent_to_admin,
  218. 'show_image' => false,
  219. 'image_size' => array( 32, 32 ),
  220. 'plain_text' => $plain_text,
  221. 'sent_to_admin' => $sent_to_admin,
  222. )
  223. );
  224. if ( empty( $zebra_check ) ) {
  225. ?>
  226. </tbody>
  227. <tfoot>
  228. <?php
  229. }
  230. $item_totals = $order->get_order_item_totals();
  231.  
  232. if ( $item_totals ) {
  233. $i = 0;
  234. foreach ( $item_totals as $total ) {
  235. $i++;
  236. ?>
  237. <tr>
  238. <th class="td tlabel-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" scope="row" colspan="1" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['label'] ); ?></th>
  239. <td class="td tvalue-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['value'] ); ?></td>
  240. </tr>
  241. <?php
  242. }
  243. }
  244. if ( empty( $zebra_check ) ) {
  245. ?>
  246. </tfoot>
  247. <?php
  248. } else {
  249. ?>
  250. </tbody>
  251. <?php
  252. }
  253. ?>
  254. </table>
  255. </div>
  256. <?php
  257. if ( $order->get_customer_note() ) {
  258. ?>
  259. <div class="email-spacing-wrap" style="margin-bottom: 40px;">
  260. <h2>
  261. <?php echo esc_html__( 'Order Note', 'kadence-woocommerce-email-designer' ); ?>
  262. </h2>
  263. <p class="note-content"><?php echo wp_kses_post( nl2br( wptexturize( $order->get_customer_note() ) ) ); ?></p>
  264. </div>
  265. <?php
  266. }
  267. ?>
  268. <?php } else { ?>
  269. <div class="email-spacing-wrap" style="margin-bottom: 40px;">
  270. <table class="td" cellspacing="0" cellpadding="6" width="100%" style="width: 100%;" border="1">
  271. <thead>
  272. <tr>
  273. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'kadence-woocommerce-email-designer' ); ?></th>
  274. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'kadence-woocommerce-email-designer' ); ?></th>
  275. <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'kadence-woocommerce-email-designer' ); ?></th>
  276. </tr>
  277. </thead>
  278. <tbody>
  279. <?php
  280. echo wc_get_email_order_items( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  281. $order,
  282. array(
  283. 'show_sku' => $sent_to_admin,
  284. 'show_image' => false,
  285. 'image_size' => array( 32, 32 ),
  286. 'plain_text' => $plain_text,
  287. 'sent_to_admin' => $sent_to_admin,
  288. )
  289. );
  290. if ( empty( $zebra_check ) ) {
  291. ?>
  292. </tbody>
  293. <tfoot>
  294. <?php
  295. }
  296. $item_totals = $order->get_order_item_totals();
  297.  
  298. if ( $item_totals ) {
  299. $i = 0;
  300. foreach ( $item_totals as $total ) {
  301. $i++;
  302. ?>
  303. <tr>
  304. <th class="td tlabel-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['label'] ); ?></th>
  305. <td class="td tvalue-<?php echo esc_attr( preg_replace( '/[^a-z]/', '', strtolower( $total['label'] ) ) ); ?>" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( $total['value'] ); ?></td>
  306. </tr>
  307. <?php
  308. }
  309. }
  310. if ( false == $note_check && $order->get_customer_note() ) {
  311. ?>
  312. <tr>
  313. <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Note:', 'kadence-woocommerce-email-designer' ); ?></th>
  314. <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( nl2br( wptexturize( $order->get_customer_note() ) ) ); ?></td>
  315. </tr>
  316. <?php
  317. }
  318. if ( empty( $zebra_check ) ) {
  319. ?>
  320. </tfoot>
  321. <?php
  322. } else {
  323. ?>
  324. </tbody>
  325. <?php
  326. }
  327. ?>
  328. </table>
  329. </div>
  330. <?php
  331. if ( true == $note_check && $order->get_customer_note() ) {
  332. ?>
  333. <div class="email-spacing-wrap" style="margin-bottom: 40px;">
  334. <h2>
  335. <?php echo esc_html__( 'Order Note', 'kadence-woocommerce-email-designer' ); ?>
  336. </h2>
  337. <p class="note-content"><?php echo wp_kses_post( nl2br( wptexturize( $order->get_customer_note() ) ) ); ?></p>
  338. </div>
  339. <?php
  340. }
  341. ?>
  342. <?php
  343. }
  344.  
  345. do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text, $email );
  346. }
  347.  
Advertisement
Add Comment
Please, Sign In to add comment