PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Shortcodes / OrderDetails / OrderDetailsRenderer.php

OrderDetailsRenderer.php in YayMail – WooCommerce Email Customizer trunk, at src/Shortcodes/OrderDetails/OrderDetailsRenderer.php

608 lines 29.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Shortcodes\OrderDetails;
4
5 use YayMail\Utils\TemplateHelpers;
6 use YayMail\Utils\Helpers;
7
8 /**
9 * @method: static OrderDetailsRenderer get_instance()
10 */
11 class OrderDetailsRenderer {
12
13 public $item_totals = [];
14
15 public $order = null;
16
17 public $order_note = '';
18
19 public $element_data = null;
20
21 public $is_placeholder = false;
22
23 public $titles = [];
24
25 public $show_product_item_cost = false;
26
27 public $colspan_value = '2';
28
29 public function __construct( $order, $element_data, $is_placeholder ) {
30 $yaymail_settings = yaymail_settings();
31 $this->show_product_item_cost = isset( $yaymail_settings['show_product_item_cost'] ) ? boolval( $yaymail_settings['show_product_item_cost'] ) : false;
32 $this->colspan_value = $is_placeholder ? '{{show_product_item_cost}}' : ( $this->show_product_item_cost ? '3' : '2' );
33 $this->element_data = $element_data;
34 $this->is_placeholder = $is_placeholder;
35 $this->initialize_titles();
36
37 if ( ! Helpers::is_woocommerce_order( $order ) ) {
38 $this->initialize_sample_data();
39 } else {
40 $this->initialize_order_data( $order );
41 }
42 }
43
44 public function initialize_titles() {
45 $this->titles = [
46 'product' => isset( $this->element_data['product_title'] ) ? $this->element_data['product_title'] : TemplateHelpers::get_content_as_placeholder( 'product_title', esc_html__( 'Product', 'woocommerce' ), $this->is_placeholder ),
47 'cost' => isset( $this->element_data['cost_title'] ) ? $this->element_data['cost_title'] : TemplateHelpers::get_content_as_placeholder( 'cost_title', esc_html__( 'Cost', 'woocommerce' ), $this->is_placeholder ),
48 'quantity' => isset( $this->element_data['quantity_title'] ) ? $this->element_data['quantity_title'] : TemplateHelpers::get_content_as_placeholder( 'quantity_title', esc_html__( 'Quantity', 'woocommerce' ), $this->is_placeholder ),
49 'price' => isset( $this->element_data['price_title'] ) ? $this->element_data['price_title'] : TemplateHelpers::get_content_as_placeholder( 'price_title', esc_html__( 'Price', 'woocommerce' ), $this->is_placeholder ),
50 'cart_subtotal' => isset( $this->element_data['cart_subtotal_title'] ) ? $this->element_data['cart_subtotal_title'] : TemplateHelpers::get_content_as_placeholder( 'cart_subtotal_title', esc_html__( 'Subtotal:', 'woocommerce' ), $this->is_placeholder ),
51 'shipping' => isset( $this->element_data['shipping_title'] ) ? $this->element_data['shipping_title'] : TemplateHelpers::get_content_as_placeholder( 'shipping_title', esc_html__( 'Shipping:', 'woocommerce' ), $this->is_placeholder ),
52 'discount' => isset( $this->element_data['discount_title'] ) ? $this->element_data['discount_title'] : TemplateHelpers::get_content_as_placeholder( 'discount_title', esc_html__( 'Discount:', 'woocommerce' ), $this->is_placeholder ),
53 'payment_method' => isset( $this->element_data['payment_method_title'] ) ? $this->element_data['payment_method_title'] : TemplateHelpers::get_content_as_placeholder( 'payment_method_title', esc_html__( 'Payment method:', 'woocommerce' ), $this->is_placeholder ),
54 'order_total' => isset( $this->element_data['order_total_title'] ) ? $this->element_data['order_total_title'] : TemplateHelpers::get_content_as_placeholder( 'order_total_title', esc_html__( 'Total:', 'woocommerce' ), $this->is_placeholder ),
55 'order_note' => isset( $this->element_data['order_note_title'] ) ? $this->element_data['order_note_title'] : TemplateHelpers::get_content_as_placeholder( 'order_note_title', esc_html__( 'Note:', 'woocommerce' ), $this->is_placeholder ),
56 ];
57 }
58
59 private function initialize_sample_data() {
60 $this->item_totals = [
61 'cart_subtotal' => [
62 'label' => $this->titles['cart_subtotal'],
63 'value' => wc_price( 18 ),
64 ],
65 'shipping' => [
66 'label' => $this->titles['shipping'],
67 'value' => __( 'Free shipping', 'yaymail' ),
68 ],
69 'order_total' => [
70 'label' => $this->titles['order_total'],
71 'value' => wc_price( 18 ),
72 ],
73 'payment_method' => [
74 'label' => $this->titles['payment_method'],
75 'value' => __( 'Direct bank transfer', 'yaymail' ),
76 ],
77 ];
78 $this->order_note = 'YayMail';
79 }
80
81 private function initialize_order_data( $order ) {
82 // Avoid appending the "via {shipping method}" suffix in the Shipping total.
83 // WooCommerce adds this suffix via the `woocommerce_order_shipping_to_display_shipped_via` filter.
84 add_filter( 'woocommerce_order_shipping_to_display_shipped_via', '__return_false', 10, 2 );
85 $this->item_totals = $order->get_order_item_totals();
86 remove_filter( 'woocommerce_order_shipping_to_display_shipped_via', '__return_false', 10 );
87 $this->order_note = $order->get_customer_note();
88 $this->order = $order;
89 }
90
91 /**
92 * Whether order details use the modern (borderless grid) layout.
93 */
94 private function is_layout_modern() {
95 return isset( $this->element_data['layout_type'] ) && 'modern' === $this->element_data['layout_type'];
96 }
97
98 public function get_styles() {
99 $base_styles = [
100 'padding' => '12px',
101 'text-align' => yaymail_get_text_align(),
102 'font-family' => TemplateHelpers::get_font_family_value(
103 $this->element_data['font_family'] ?? 'inherit'
104 ),
105 'color' => $this->element_data['text_color'] ?? 'inherit',
106 ];
107
108 if ( $this->is_layout_modern() ) {
109 return TemplateHelpers::get_style( $base_styles );
110 }
111
112 $border_styles = [
113 'border-width' => '1px',
114 'border-style' => 'solid',
115 'border-color' => $this->element_data['border_color'] ?? 'inherit',
116 ];
117
118 return TemplateHelpers::get_style( array_merge( $base_styles, $border_styles ) );
119 }
120
121 public function get_styles_product_image() {
122 $direction = yaymail_get_email_direction();
123
124 if ( 'ltr' === $direction ) {
125 $margin_right = '5px';
126 $margin_left = '0';
127 } else {
128 $margin_right = '0';
129 $margin_left = '5px';
130 }
131
132 return TemplateHelpers::get_style(
133 [
134 'margin-bottom' => '5px',
135 'margin-right' => $margin_right,
136 'margin-left' => $margin_left,
137 ]
138 );
139 }
140
141 public function get_structure_table() {
142 return apply_filters(
143 'yaymail_order_details_structure_table',
144 [
145 'items' => [
146 'product' => [
147 'label' => $this->titles['product'],
148 'col_span' => apply_filters( 'yaymail_order_item_product_title_colspan', 1, $this->element_data ),
149 'style' => [
150 'word-wrap' => 'break-word',
151 'width' => $this->show_product_item_cost ? '40%' : '45%',
152 ],
153 ],
154 'cost' => [
155 'label' => $this->titles['cost'],
156 'col_span' => apply_filters( 'yaymail_order_item_cost_colspan', 1, $this->element_data ),
157 'style' => [
158 'min-width' => '65px',
159 ],
160 ],
161 'quantity' => [
162 'label' => $this->titles['quantity'],
163 'col_span' => apply_filters( 'yaymail_order_item_quantity_colspan', 1, $this->element_data ),
164 'style' => [
165 'min-width' => '85px',
166 ],
167 ],
168 'price' => [
169 'label' => $this->titles['price'],
170 'col_span' => apply_filters( 'yaymail_order_item_price_colspan', 1, $this->element_data ),
171 'style' => [
172 'word-wrap' => 'break-word',
173 'min-width' => '100px',
174 'width' => $this->show_product_item_cost ? '28%' : '38%',
175 ],
176
177 ],
178 ],
179 'footer' => [
180 'label_col_span' => $this->colspan_value,
181 'value_col_span' => 1,
182 'hidden_rows' => [],
183 ],
184 ]
185 );
186 }
187
188 public function render() {
189 if ( $this->is_layout_modern() ) {
190 $table_style = TemplateHelpers::get_style(
191 [
192 'width' => '100%',
193 'border' => '0',
194 'border-collapse' => 'collapse',
195 'mso-table-lspace' => '0pt',
196 'mso-table-rspace' => '0pt',
197 'padding' => '0',
198 'color' => isset( $this->element_data['text_color'] ) ? $this->element_data['text_color'] : 'inherit',
199 'font-family' => TemplateHelpers::get_font_family_value( isset( $this->element_data['font_family'] ) ? $this->element_data['font_family'] : 'inherit' ),
200 ]
201 );
202 $border_attr = 0;
203 } else {
204 $table_style = $this->get_styles() . 'padding: 0;border-collapse: separate;';
205 $border_attr = 1;
206 }
207 ?>
208 <table class="yaymail-order-details-table"<?php echo $this->is_layout_modern() ? ' data-layout-type-modern="true"' : ''; ?> cellspacing="0" cellpadding="6" width="100%" style="<?php echo esc_attr( $table_style ); ?>" border="<?php echo esc_attr( (string) $border_attr ); ?>">
209 <?php
210 $this->render_heading();
211 $this->render_order_items();
212 $this->render_footer();
213 ?>
214 </table>
215 <?php
216 }
217
218 public function render_heading() {
219 $styles = $this->get_styles();
220 $structure_table = $this->get_structure_table();
221 $structure_items = isset( $structure_table['items'] ) ? $structure_table['items'] : [];
222 if ( isset( $structure_items['cost'] ) && ! $this->show_product_item_cost && ! $this->is_placeholder ) {
223 unset( $structure_items['cost'] );
224 }
225 ?>
226 <thead class="yaymail_element_head_order_details yaymail_element_head_order_item">
227 <tr>
228 <?php
229 foreach ( $structure_items as $key => $structure_item ) :
230 if ( isset( $structure_item['width'] ) ) {
231 $width = 'width: ' . $structure_item['width'] . ';';
232 } else {
233 $width = '';
234 }
235 $item_style = isset( $structure_item['style'] ) ? $structure_item['style'] : [];
236 if ( ! empty( $item_style ) ) {
237 $item_style_string = TemplateHelpers::get_style( $item_style );
238 } else {
239 $item_style_string = '';
240 }
241 $column_style = $styles . $width . $item_style_string;
242 echo '<th class="td yaymail_item_' . esc_attr( $key ) . '_title" colspan="' . esc_attr( $structure_item['col_span'] ) . '" scope="col" style="' . esc_attr( $column_style ) . ';"><span>' . esc_html( $structure_item['label'] ) . '</span></th>';
243 endforeach;
244 ?>
245 </tr>
246 </thead>
247 <?php
248 }
249
250 public function render_order_items() {
251 $structure_table = $this->get_structure_table();
252 $structure_items = isset( $structure_table['items'] ) ? $structure_table['items'] : [];
253 if ( isset( $structure_items['cost'] ) && ! $this->show_product_item_cost && ! $this->is_placeholder ) {
254 unset( $structure_items['cost'] );
255 }
256 ?>
257 <tbody class="yaymail_element_body_order_details yaymail_element_body_order_item">
258 <?php
259 if ( null === $this->order || ! ( $this->order instanceof \WC_Order ) || ( 12345 === $this->order->get_id() && ! wc_get_order( 12345 ) ) ) {
260 $this->render_sample_items( $structure_items );
261 } else {
262 $this->render_real_items( $structure_items );
263 }
264 ?>
265 </tbody>
266 <?php
267 }
268
269 public function render_sample_items( $structure_items ) {
270 $yaymail_settings = yaymail_settings();
271 $direction = yaymail_get_email_direction();
272 $image_position = isset( $yaymail_settings['product_image_position'] ) ? $yaymail_settings['product_image_position'] : 'top';
273
274 $style_image_position_left = TemplateHelpers::get_style(
275 [
276 'float' => 'left' === $image_position && 'rtl' === $direction ? 'right' : 'left',
277 ]
278 );
279
280 $style = $this->get_styles();
281 $is_placeholder = $this->is_placeholder;
282
283 $show_image = isset( $yaymail_settings['show_product_image'] ) ? boolval( $yaymail_settings['show_product_image'] ) : false;
284 $image_height = isset( $yaymail_settings['product_image_height'] ) ? $yaymail_settings['product_image_height'] : '30';
285 $image_width = isset( $yaymail_settings['product_image_width'] ) ? $yaymail_settings['product_image_width'] : '30';
286
287 $show_image = isset( $yaymail_settings['show_product_image'] ) ? boolval( $yaymail_settings['show_product_image'] ) : false;
288 $show_sku = isset( $yaymail_settings['show_product_sku'] ) ? boolval( $yaymail_settings['show_product_sku'] ) : false;
289 $show_des = isset( $yaymail_settings['show_product_description'] ) ? boolval( $yaymail_settings['show_product_description'] ) : false;
290 $show_regular_price = isset( $yaymail_settings['show_product_regular_price'] ) ? boolval( $yaymail_settings['show_product_regular_price'] ) : false;
291 $show_hyper_links = isset( $yaymail_settings['show_product_hyper_links'] ) ? boolval( $yaymail_settings['show_product_hyper_links'] ) : false;
292 $image_style = 'left' === $image_position ? $this->get_styles_product_image() . $style_image_position_left : $this->get_styles_product_image();
293
294 $image_url = wc_placeholder_img_src();
295 $image = $is_placeholder ? "<img style='margin-right:0;' width='{{product_image_width}}px' height='{{product_image_height}}px' src='{$image_url}' alt='product image'/>" : "<img style='margin-right: 0; width: {$image_width}px; height: {$image_height}px;' src='{$image_url}' alt='product image'/>";
296 $sku = __( 'sku', 'yaymail' );
297 $short_description = __( 'Product short description', 'yaymail' );
298 $product_name = __( 'Happy YayCommerce', 'yaymail' );
299 $product_permalink = '#';
300 $product_hyper_link = "<a href='{$product_permalink}' target='_blank'>{$product_name}</a>";
301 $product_cost = 9;
302 $product_quantity = 2;
303 $product_regular_price = 10;
304
305 $is_layout_type_modern = isset( $this->element_data['layout_type'] ) && 'modern' === $this->element_data['layout_type'];
306 ?>
307 <tr class="order_item yaymail-order-item-last">
308 <?php foreach ( $structure_items as $key => $structure_item ) : ?>
309 <?php
310 if ( isset( $structure_item['width'] ) ) {
311 $width = 'width: ' . $structure_item['width'] . ';';
312 } else {
313 $width = '';
314 }
315 $item_style = isset( $structure_item['style'] ) ? $structure_item['style'] : [];
316 if ( ! empty( $item_style ) ) {
317 $item_style_string = TemplateHelpers::get_style( $item_style );
318 } else {
319 $item_style_string = '';
320 }
321 $column_style = $style . $width . $item_style_string;
322 ?>
323 <td colspan="<?php echo esc_attr( $structure_item['col_span'] ); ?>" class="td yaymail_item_<?php echo esc_attr( $key ); ?>_content" scope="row" style="<?php echo esc_attr( $column_style ); ?>">
324 <?php
325 switch ( $key ) :
326 case 'product':
327 // Show title/image etc.
328 if ( ( $show_image && 'bottom' !== $image_position ) || $is_placeholder ) {
329 echo wp_kses_post( "<div class='yaymail-product_image_position__top' style='{$image_style}'>" );
330 require YAYMAIL_PLUGIN_PATH . 'templates/shortcodes/order-details/order-items/image-content.php';
331 echo ( '</div>' );
332 }
333 ?>
334
335 <!-- Product details -->
336 <div class='yaymail-product-details'>
337 <?php
338
339 // Product name.
340 require YAYMAIL_PLUGIN_PATH . 'templates/shortcodes/order-details/order-items/product-name-content.php';
341
342 // SKU.
343 if ( ( $show_sku && ! empty( $sku ) ) || ( $is_placeholder && ! empty( $sku ) ) ) {
344 require YAYMAIL_PLUGIN_PATH . 'templates/shortcodes/order-details/order-items/sku-content.php';
345 }
346
347 // Product Description.
348 if ( ( $show_des && ! empty( $short_description ) ) || ( $is_placeholder && ! empty( $short_description ) ) ) {
349 require YAYMAIL_PLUGIN_PATH . 'templates/shortcodes/order-details/order-items/product-short-description-content.php';
350 }
351
352 // Show title/image etc in bottom.
353 if ( ( $show_image && 'bottom' === $image_position ) || $is_placeholder ) {
354 echo wp_kses_post( "<div class='yaymail-product_image_position__bottom' style='{$image_style}'>" );
355 require YAYMAIL_PLUGIN_PATH . 'templates/shortcodes/order-details/order-items/image-content.php';
356 echo ( '</div>' );
357 }
358 ?>
359 </div>
360 <!-- End Product details -->
361 <?php
362 break;
363 case 'cost':
364 echo wp_kses_post( wc_price( $product_cost ) );
365 break;
366 case 'quantity':
367 ?>
368 <?php if ( $is_layout_type_modern || $is_placeholder ) : ?>
369 <span class="yaymail-quantity-type-modern">x</span>
370 <?php endif; ?>
371 <?php
372 echo wp_kses_post( $product_quantity );
373 break;
374 case 'price':
375 // Show product regular price.
376 if ( ( $show_regular_price ) ) {
377 ?>
378 <del class="yaymail-product-regular-price" style="padding-right:5px"> <?php echo wp_kses_post( wc_price( $product_regular_price * $product_quantity ) ); ?> </del>
379 <?php
380 }
381 echo wp_kses_post( wc_price( $product_cost * $product_quantity ) );
382 break;
383 default:
384 yaymail_kses_post_e( do_action( 'yaymail_order_details_item_' . $key . '_content', null, $this->order, $this->element_data, true ) );
385 break;
386 endswitch;
387 ?>
388 </td>
389 <?php endforeach; ?>
390 </tr>
391 <?php
392 }
393
394 public function render_real_items( $structure_items ) {
395 $yaymail_settings = yaymail_settings();
396 $direction = yaymail_get_email_direction();
397 $image_position = isset( $yaymail_settings['product_image_position'] ) ? $yaymail_settings['product_image_position'] : 'top';
398
399 $style_image_position_left = TemplateHelpers::get_style(
400 [
401 'float' => 'left' === $image_position && 'rtl' === $direction ? 'right' : 'left',
402 ]
403 );
404
405 $args_data = [
406 'order' => $this->order,
407 'text_style' => $this->get_styles(),
408 'styles_product_image' => 'left' === $image_position ? $this->get_styles_product_image() . $style_image_position_left : $this->get_styles_product_image(),
409 'is_placeholder' => $this->is_placeholder,
410 'structure_items' => $structure_items,
411 ];
412
413 // Just has data when send mail
414 if ( ! empty( $this->element_data ) ) {
415 $args_data['element'] = $this->element_data;
416 }
417 $path_data = apply_filters( 'yaymail_order_details_items', 'templates/shortcodes/order-details/order-items/main.php' );
418 $html = yaymail_get_content( $path_data, $args_data );
419 $allowed_html = TemplateHelpers::wp_kses_allowed_html();
420 echo wp_kses( $html, $allowed_html );
421 }
422
423 public function render_footer() {
424 $structure_table = $this->get_structure_table();
425 $structure_footer = isset( $structure_table['footer'] ) ? $structure_table['footer'] : [];
426
427 if ( empty( $structure_footer ) ) {
428 return;
429 }
430 // TODO: change class name
431 ?>
432 <tfoot class="yaymail_element_foot_order_details yaymail_element_foot_order_item">
433 <?php
434 $this->render_item_totals( $structure_footer );
435
436 if ( ! empty( $this->order ) && $this->order->get_customer_note() ) {
437 $this->render_customer_note( $structure_footer );
438 }
439 ?>
440 </tfoot>
441 <?php
442 }
443
444 public function render_item_totals( $structure_footer ) {
445 $custom_rows = isset( $this->element_data['custom_footer_rows'] )
446 ? $this->element_data['custom_footer_rows']
447 : [];
448
449 // Group custom rows by zone
450 $rows_by_zone = [
451 'before_all' => [],
452 'after_subtotal' => [],
453 'before_total' => [],
454 'after_total' => [],
455 ];
456
457 foreach ( $custom_rows as $row ) {
458 // Check if row is enabled - handle both boolean and string values
459 $is_enabled = isset( $row['enabled'] ) ? boolval( $row['enabled'] ) : false;
460
461 if ( $is_enabled && isset( $row['zone'] ) ) {
462 $zone = $row['zone'];
463 if ( isset( $rows_by_zone[ $zone ] ) ) {
464 $rows_by_zone[ $zone ][] = $row;
465 }
466 }
467 }
468
469 // Sort each zone by order
470 foreach ( $rows_by_zone as &$zone_rows ) {
471 usort(
472 $zone_rows,
473 function( $a, $b ) {
474 $order_a = isset( $a['order'] ) ? intval( $a['order'] ) : 0;
475 $order_b = isset( $b['order'] ) ? intval( $b['order'] ) : 0;
476 return $order_a - $order_b;
477 }
478 );
479 }
480
481 $index = 0;
482
483 // ZONE 1: Before all
484 foreach ( $rows_by_zone['before_all'] as $row ) {
485 $this->render_custom_row( $row, $index++, $structure_footer );
486 }
487
488 // Process standard rows
489 foreach ( $this->item_totals as $key => $total ) {
490 if ( in_array( $key, $structure_footer['hidden_rows'] ?? [], true ) ) {
491 continue;
492 }
493
494 // ZONE 2: After subtotal
495 if ( 'cart_subtotal' === $key ) {
496 $this->render_standard_row( $key, $total, $index++, $structure_footer );
497 foreach ( $rows_by_zone['after_subtotal'] as $row ) {
498 $this->render_custom_row( $row, $index++, $structure_footer );
499 }
500 continue;
501 }
502
503 // ZONE 3: Before total
504 if ( 'order_total' === $key ) {
505 foreach ( $rows_by_zone['before_total'] as $row ) {
506 $this->render_custom_row( $row, $index++, $structure_footer );
507 }
508 $this->render_standard_row( $key, $total, $index++, $structure_footer );
509 continue;
510 }
511
512 // Other rows - render normally
513 $this->render_standard_row( $key, $total, $index++, $structure_footer );
514 }//end foreach
515
516 // ZONE 4: After all (after total)
517 foreach ( $rows_by_zone['after_total'] as $row ) {
518 $this->render_custom_row( $row, $index++, $structure_footer );
519 }
520 }
521
522 /**
523 * Render a standard order total row
524 *
525 * @param string $key The order total key.
526 * @param array $total The order total data.
527 * @param int $index The row index.
528 * @param array $structure_footer The footer structure data.
529 */
530 private function render_standard_row( $key, $total, $index, $structure_footer ) {
531 $tr_class = "yaymail-order-detail-row-{$key}";
532 $can_apply_placeholder = $this->is_placeholder && isset( $this->titles[ $key ] );
533 $label = TemplateHelpers::get_content_as_placeholder( "{$key}_title", esc_html( isset( $this->titles[ $key ] ) ? $this->titles[ $key ] : $total['label'] ), $can_apply_placeholder );
534 $style = $this->get_styles();
535
536 if ( ! $this->is_layout_modern() ) {
537 $style .= TemplateHelpers::get_style(
538 [
539 'border-top-width' => ( $index === 1 ) ? '4px' : '0',
540 ]
541 );
542 }
543
544 $heading_style = $style . 'font-size: ' . ( isset( $this->element_data['table_heading_font_size'] ) ? $this->element_data['table_heading_font_size'] : '14' ) . 'px;';
545 $content_style = $style . 'font-size: ' . ( isset( $this->element_data['table_content_font_size'] ) ? $this->element_data['table_content_font_size'] : '14' ) . 'px;';
546 ?>
547 <tr class="<?php echo esc_attr( $tr_class ); ?>">
548 <th class="td" scope="row" colspan="<?php echo esc_attr( isset( $structure_footer['label_col_span'] ) ? $structure_footer['label_col_span'] : $this->colspan_value ); ?>" style="<?php echo esc_attr( $heading_style ); ?>"><?php echo wp_kses_post( do_shortcode( $label ) ); ?></th>
549 <td class="td" colspan="<?php echo esc_attr( isset( $structure_footer['value_col_span'] ) ? $structure_footer['value_col_span'] : 1 ); ?>" style="<?php echo esc_attr( $content_style ); ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>
550 </tr>
551 <?php
552 }
553
554 /**
555 * Render a custom footer row
556 *
557 * @param array $custom_row The custom row data.
558 * @param int $index The row index.
559 * @param array $structure_footer The footer structure data.
560 */
561 private function render_custom_row( $custom_row, $index, $structure_footer ) {
562 // Process shortcodes in label and value
563 $label = isset( $custom_row['label'] ) ? do_shortcode( $custom_row['label'] ) : '';
564 $value = isset( $custom_row['value'] ) ? do_shortcode( $custom_row['value'] ) : '';
565
566 if ( empty( $label ) && empty( $value ) ) {
567 return;
568 }
569
570 $style = $this->is_layout_modern()
571 ? ''
572 : $this->get_styles() . TemplateHelpers::get_style(
573 [
574 'border-top-width' => ( $index === 1 ) ? '4px' : '0',
575 ]
576 );
577
578 $heading_style = $style . 'font-size: ' . ( isset( $this->element_data['table_heading_font_size'] ) ? $this->element_data['table_heading_font_size'] : '14' ) . 'px;';
579 $content_style = $style . 'font-size: ' . ( isset( $this->element_data['table_content_font_size'] ) ? $this->element_data['table_content_font_size'] : '14' ) . 'px;';
580
581 $row_id = isset( $custom_row['id'] ) ? esc_attr( $custom_row['id'] ) : '';
582 ?>
583 <tr class="yaymail-order-detail-row-custom custom-row-<?php echo esc_attr( $row_id ); ?>">
584 <th class="td" scope="row" colspan="<?php echo esc_attr( isset( $structure_footer['label_col_span'] ) ? $structure_footer['label_col_span'] : $this->colspan_value ); ?>"
585 style="<?php echo esc_attr( $heading_style ); ?>">
586 <?php echo wp_kses_post( $label ); ?>
587 </th>
588 <td class="td" colspan="<?php echo esc_attr( isset( $structure_footer['value_col_span'] ) ? $structure_footer['value_col_span'] : 1 ); ?>"
589 style="<?php echo esc_attr( $content_style ); ?>">
590 <?php echo wp_kses_post( $value ); ?>
591 </td>
592 </tr>
593 <?php
594 }
595
596 public function render_customer_note() {
597 if ( ! empty( $this->order_note ) ) :
598 $style = $this->get_styles();
599 ?>
600 <tr class="yaymail-order-detail-row-order_note">
601 <th class="td" scope="row" colspan="<?php echo esc_attr( $this->colspan_value ); ?>" style="<?php echo esc_attr( $style ); ?>;"><?php echo esc_html( $this->titles['order_note'] ); ?></th>
602 <td class="td" style="<?php echo esc_attr( $style ); ?>;"><?php echo wp_kses_post( nl2br( wptexturize( $this->order_note ) ) ); ?></td>
603 </tr>
604 <?php
605 endif;
606 }
607 }
608