| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
use YayMail\Utils\Helpers; |
| 5 |
use YayMail\Utils\TemplateHelpers; |
| 6 |
|
| 7 |
/** |
| 8 |
* $args includes |
| 9 |
* $element |
| 10 |
* $render_data |
| 11 |
* $is_nested |
| 12 |
*/ |
| 13 |
if ( empty( $args['element'] ) ) { |
| 14 |
return; |
| 15 |
} |
| 16 |
|
| 17 |
$yaymail_settings = yaymail_settings(); |
| 18 |
$payment_display_mode = isset( $yaymail_settings['payment_display_mode'] ) ? $yaymail_settings['payment_display_mode'] : false; |
| 19 |
|
| 20 |
$element = $args['element']; |
| 21 |
$data = $element['data']; |
| 22 |
$template_name = isset( $args['template']->get_data()['name'] ) ? $args['template']->get_data()['name'] : ''; |
| 23 |
$border_color = isset( $element['data']['border_color'] ) ? $element['data']['border_color'] : 'inherit'; |
| 24 |
$table_heading_font_size = isset( $data['table_heading_font_size'] ) ? $data['table_heading_font_size'] : 14; |
| 25 |
$table_content_font_size = isset( $data['table_content_font_size'] ) ? $data['table_content_font_size'] : 14; |
| 26 |
|
| 27 |
$wrapper_style = TemplateHelpers::get_style( |
| 28 |
[ |
| 29 |
'word-break' => 'break-word', |
| 30 |
'background-color' => $data['background_color'], |
| 31 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data['padding'] ) ? $data['padding'] : [] ), |
| 32 |
] |
| 33 |
); |
| 34 |
|
| 35 |
$table_title_style = TemplateHelpers::get_style( |
| 36 |
[ |
| 37 |
'text-align' => yaymail_get_text_align(), |
| 38 |
'color' => isset( $data['title_color'] ) ? $data['title_color'] : 'inherit', |
| 39 |
'margin-top' => '0', |
| 40 |
'font-family' => TemplateHelpers::get_font_family_value( isset( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 41 |
'margin-bottom' => '7px', |
| 42 |
] |
| 43 |
); |
| 44 |
|
| 45 |
$payment_instructions_style = TemplateHelpers::get_style( |
| 46 |
[ |
| 47 |
'text-align' => yaymail_get_text_align(), |
| 48 |
'font-size' => '14px', |
| 49 |
'color' => isset( $data['text_color'] ) ? $data['text_color'] : 'inherit', |
| 50 |
'font-family' => TemplateHelpers::get_font_family_value( isset( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 51 |
'margin-bottom' => '10px', |
| 52 |
] |
| 53 |
); |
| 54 |
|
| 55 |
$is_layout_type_modern = isset( $data['layout_type'] ) && 'modern' === $data['layout_type']; |
| 56 |
$show_table_header = ! isset( $data['show_table_header'] ) || Helpers::is_true( $data['show_table_header'] ); |
| 57 |
|
| 58 |
ob_start(); |
| 59 |
?> |
| 60 |
<style> |
| 61 |
/* Modern layout */ |
| 62 |
<?php if ( $is_layout_type_modern ) { ?> |
| 63 |
<?php |
| 64 |
$modern_line_color = ( '' === (string) $border_color || 'inherit' === strtolower( (string) $border_color ) ) ? '#dddddd' : $border_color; |
| 65 |
?> |
| 66 |
|
| 67 |
|
| 68 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table { |
| 69 |
border: 0 !important; |
| 70 |
} |
| 71 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table th, |
| 72 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table td { |
| 73 |
border: 0 !important; |
| 74 |
padding-left: 0 !important; |
| 75 |
padding-right: 0 !important; |
| 76 |
} |
| 77 |
|
| 78 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> th.yaymail_item_price_title, |
| 79 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> td.yaymail_item_price_content, |
| 80 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail_element_foot_order_details tr td { |
| 81 |
text-align: right !important; |
| 82 |
} |
| 83 |
|
| 84 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail_item_quantity_title, |
| 85 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail_item_quantity_content, |
| 86 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail_item_cost_title, |
| 87 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail_item_cost_content { |
| 88 |
text-align: center !important; |
| 89 |
} |
| 90 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-quantity-type-modern { |
| 91 |
display: inline-block !important; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table tbody.yaymail_element_body_order_details .yaymail-order-item-last td{ |
| 96 |
border-bottom: 1px solid <?php echo esc_attr( $modern_line_color ); ?> !important; |
| 97 |
} |
| 98 |
|
| 99 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table .yaymail-order-detail-row-payment_method td, |
| 100 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table .yaymail-order-detail-row-payment_method th { |
| 101 |
border-bottom: 1px solid <?php echo esc_attr( $modern_line_color ); ?> !important; |
| 102 |
} |
| 103 |
|
| 104 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table th { |
| 105 |
font-size: <?php echo esc_attr( $table_heading_font_size ); ?>px !important; |
| 106 |
} |
| 107 |
|
| 108 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-table td { |
| 109 |
font-size: <?php echo esc_attr( $table_content_font_size ); ?>px !important; |
| 110 |
} |
| 111 |
|
| 112 |
<?php |
| 113 |
}//end if |
| 114 |
?> |
| 115 |
|
| 116 |
/* Hide table header */ |
| 117 |
<?php if ( ! $show_table_header ) { ?> |
| 118 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail_element_head_order_details { |
| 119 |
display: none !important; |
| 120 |
} |
| 121 |
<?php } ?> |
| 122 |
</style> |
| 123 |
|
| 124 |
<div class="yaymail-order-details-title" style="<?php echo esc_attr( $table_title_style ); ?>" > <?php echo wp_kses_post( do_shortcode( $data['title'] ) ); ?> </div> |
| 125 |
<?php |
| 126 |
$element_content = ob_get_contents(); |
| 127 |
ob_end_clean(); |
| 128 |
$element_content .= yaymail_kses_post( do_shortcode( isset( $data['rich_text'] ) ? $data['rich_text'] : '' ) ); |
| 129 |
TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style ); |
| 130 |
|