PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.3
YayMail – WooCommerce Email Customizer v4.3.3
4.4.7 4.4.6 4.4.5 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 All 58 releases
← All changes | src/Shortcodes/OrderDetails/OrderDetailsRenderer.php +35 -79 4.4.6 → 4.3.3 View file →
@@ -65,58 +65,38 @@
65 65 'shipping' => [
66 66 'label' => $this->titles['shipping'],
67 67 'value' => __( 'Free shipping', 'yaymail' ),
68 68 ],
69 + 'payment_method' => [
70 + 'label' => $this->titles['payment_method'],
71 + 'value' => __( 'Direct bank transfer', 'yaymail' ),
72 + ],
69 73 'order_total' => [
70 74 'label' => $this->titles['order_total'],
71 75 'value' => wc_price( 18 ),
72 76 ],
73 - 'payment_method' => [
74 - 'label' => $this->titles['payment_method'],
75 - 'value' => __( 'Direct bank transfer', 'yaymail' ),
76 - ],
77 77 ];
78 78 $this->order_note = 'YayMail';
79 79 }
80 80
81 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 82 $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;
83 + $this->order_note = $order->get_customer_note();
84 + $this->order = $order;
89 85 }
90 86
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 87 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 ) );
88 + return TemplateHelpers::get_style(
89 + [
90 + 'padding' => '12px',
91 + 'text-align' => yaymail_get_text_align(),
92 + 'font-family' => TemplateHelpers::get_font_family_value( isset( $this->element_data['font_family'] ) ? $this->element_data['font_family'] : 'inherit' ),
93 + 'color' => isset( $this->element_data['text_color'] ) ? $this->element_data['text_color'] : 'inherit',
94 + 'border-width' => '1px',
95 + 'border-style' => 'solid',
96 + 'border-color' => isset( $this->element_data['border_color'] ) ? $this->element_data['border_color'] : 'inherit',
97 + ]
98 + );
119 99 }
120 100
121 101 public function get_styles_product_image() {
122 102 $direction = yaymail_get_email_direction();
@@ -185,28 +165,11 @@
185 165 );
186 166 }
187 167
188 168 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 - }
169 + $style = $this->get_styles() . 'padding: 0;border-collapse: separate;';
207 170 ?>
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 ); ?>">
171 + <table class="yaymail-order-details-table" cellspacing="0" cellpadding="6" width="100%" style="<?php echo esc_attr( $style ); ?>" border="1">
209 172 <?php
210 173 $this->render_heading();
211 174 $this->render_order_items();
212 175 $this->render_footer();
@@ -255,9 +218,9 @@
255 218 }
256 219 ?>
257 220 <tbody class="yaymail_element_body_order_details yaymail_element_body_order_item">
258 221 <?php
259 - if ( null === $this->order || ! ( $this->order instanceof \WC_Order ) || ( 12345 === $this->order->get_id() && ! wc_get_order( 12345 ) ) ) {
222 + if ( null === $this->order || ! ( $this->order instanceof \WC_Order ) || 12345 === $this->order->get_id() ) {
260 223 $this->render_sample_items( $structure_items );
261 224 } else {
262 225 $this->render_real_items( $structure_items );
263 226 }
@@ -303,9 +266,9 @@
303 266 $product_regular_price = 10;
304 267
305 268 $is_layout_type_modern = isset( $this->element_data['layout_type'] ) && 'modern' === $this->element_data['layout_type'];
306 269 ?>
307 - <tr class="order_item yaymail-order-item-last">
270 + <tr class="order_item">
308 271 <?php foreach ( $structure_items as $key => $structure_item ) : ?>
309 272 <?php
310 273 if ( isset( $structure_item['width'] ) ) {
311 274 $width = 'width: ' . $structure_item['width'] . ';';
@@ -380,9 +343,9 @@
380 343 }
381 344 echo wp_kses_post( wc_price( $product_cost * $product_quantity ) );
382 345 break;
383 346 default:
384 - yaymail_kses_post_e( do_action( 'yaymail_order_details_item_' . $key . '_content', null, $this->order, $this->element_data, true ) );
347 + echo wp_kses_post( do_action( 'yaymail_order_details_item_' . $key . '_content', null, $this->order, $this->element_data, true ) );
385 348 break;
386 349 endswitch;
387 350 ?>
388 351 </td>
@@ -530,23 +493,18 @@
530 493 private function render_standard_row( $key, $total, $index, $structure_footer ) {
531 494 $tr_class = "yaymail-order-detail-row-{$key}";
532 495 $can_apply_placeholder = $this->is_placeholder && isset( $this->titles[ $key ] );
533 496 $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;';
497 + $style = $this->get_styles() . TemplateHelpers::get_style(
498 + [
499 + 'border-top-width' => 1 === $index ? '4px' : '0',
500 + ]
501 + );
502 + $heading_style = $style . 'font-size: ' . ( isset( $this->element_data['table_heading_font_size'] ) ? $this->element_data['table_heading_font_size'] : '14' ) . 'px;';
503 + $content_style = $style . 'font-size: ' . ( isset( $this->element_data['table_content_font_size'] ) ? $this->element_data['table_content_font_size'] : '14' ) . 'px;';
546 504 ?>
547 505 <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>
506 + <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( $label ); ?></th>
549 507 <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 508 </tr>
551 509 <?php
552 510 }
@@ -566,15 +524,13 @@
566 524 if ( empty( $label ) && empty( $value ) ) {
567 525 return;
568 526 }
569 527
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 - );
528 + $style = $this->get_styles() . TemplateHelpers::get_style(
529 + [
530 + 'border-top-width' => 1 === $index ? '4px' : '0',
531 + ]
532 + );
577 533
578 534 $heading_style = $style . 'font-size: ' . ( isset( $this->element_data['table_heading_font_size'] ) ? $this->element_data['table_heading_font_size'] : '14' ) . 'px;';
579 535 $content_style = $style . 'font-size: ' . ( isset( $this->element_data['table_content_font_size'] ) ? $this->element_data['table_content_font_size'] : '14' ) . 'px;';
580 536