| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || exit; |
| 4 |
use YayMail\Page\Source\CustomPostType; |
| 5 |
use YayMail\Helper\Helper; |
| 6 |
$is_preview = Helper::isPreview( $this->preview_mail ); |
| 7 |
$text_align = is_rtl() ? 'right' : 'left'; |
| 8 |
$sent_to_admin = ( isset( $sent_to_admin ) ? true : false ); |
| 9 |
$plain_text = ( isset( $plain_text ) ? $plain_text : '' ); |
| 10 |
$email = ( isset( $email ) ? $email : '' ); |
| 11 |
$postID = CustomPostType::postIDByTemplate( $this->template ); |
| 12 |
$yaymail_settings = get_option( 'yaymail_settings' ); |
| 13 |
$yaymail_template = get_post_meta( $postID, '_yaymail_template', true ); |
| 14 |
$order_item_title = get_post_meta( $postID, '_yaymail_email_order_item_title', true ); |
| 15 |
$product_title = $is_preview ? '{{product_title}}' : ( false != $order_item_title && isset( $order_item_title['product_title'] ) ? $order_item_title['product_title'] : 'Product' ); |
| 16 |
$cost_title = $is_preview ? '{{cost_title}}' : ( false != $order_item_title && isset( $order_item_title['cost_title'] ) ? $order_item_title['cost_title'] : 'Cost' ); |
| 17 |
$quantity_title = $is_preview ? '{{quantity_title}}' : ( false != $order_item_title && isset( $order_item_title['quantity_title'] ) ? $order_item_title['quantity_title'] : 'Quantity' ); |
| 18 |
$price_title = $is_preview ? '{{price_title}}' : ( false != $order_item_title && isset( $order_item_title['price_title'] ) ? $order_item_title['price_title'] : 'Price' ); |
| 19 |
$subtoltal_title = $is_preview ? '{{subtoltal_title}}' : ( false != $order_item_title && isset( $order_item_title['subtoltal_title'] ) ? $order_item_title['subtoltal_title'] : 'Subtotal:' ); |
| 20 |
$discount_title = $is_preview ? '{{discount_title}}' : ( false != $order_item_title && isset( $order_item_title['discount_title'] ) ? $order_item_title['discount_title'] : 'Discount:' ); |
| 21 |
$shipping_title = $is_preview ? '{{shipping_title}}' : ( false != $order_item_title && isset( $order_item_title['shipping_title'] ) ? $order_item_title['shipping_title'] : 'Shipping:' ); |
| 22 |
$payment_method_title = $is_preview ? '{{payment_method_title}}' : ( false != $order_item_title && isset( $order_item_title['payment_method_title'] ) ? $order_item_title['payment_method_title'] : 'Payment method:' ); |
| 23 |
$total_title = $is_preview ? '{{total_title}}' : ( false != $order_item_title && isset( $order_item_title['total_title'] ) ? $order_item_title['total_title'] : 'Total:' ); |
| 24 |
$fully_refunded = $is_preview ? '{{fully_refunded}}' : ( false != $order_item_title && isset( $order_item_title['fully_refunded'] ) ? $order_item_title['fully_refunded'] : 'Order fully refunded.' ); |
| 25 |
$customer_note = $is_preview ? '{{customer_note}}' : ( false != $order_item_title && isset( $order_item_title['customer_note'] ) ? $order_item_title['customer_note'] : 'Note:' ); |
| 26 |
$get_order_item_totals = array( |
| 27 |
'cart_subtotal' => $subtoltal_title, |
| 28 |
'discount' => $discount_title, |
| 29 |
'shipping' => $shipping_title, |
| 30 |
'payment_method' => $payment_method_title, |
| 31 |
'order_total' => $total_title, |
| 32 |
'refund_0' => $fully_refunded, |
| 33 |
'customer_note' => $customer_note, |
| 34 |
); |
| 35 |
|
| 36 |
$get_order_item_totals_class = array( |
| 37 |
'cart_subtotal' => 'yaymail_item_subtoltal_title', |
| 38 |
'discount' => 'yaymail_item_discount_title', |
| 39 |
'payment_method' => 'yaymail_item_payment_method_title', |
| 40 |
'order_total' => 'yaymail_item_total_title', |
| 41 |
'shipping' => 'yaymail_item_shipping_title', |
| 42 |
'refund_0' => 'yaymail_item_fully_refunded', |
| 43 |
'tax' => 'yaymail_item_tax', |
| 44 |
'customer_note' => 'yaymail_item_customer_note', |
| 45 |
); |
| 46 |
$item_content_class = array( |
| 47 |
'cart_subtotal' => 'yaymail_item_subtoltal_content', |
| 48 |
'payment_method' => 'yaymail_item_payment_method_content', |
| 49 |
'order_total' => 'yaymail_item_total_content', |
| 50 |
'shipping' => 'yaymail_item_shipping_content', |
| 51 |
'refund_0' => 'yaymail_item_fully_refunded_content', |
| 52 |
'customer_note' => 'yaymail_item_customer_note_content', |
| 53 |
); |
| 54 |
$borderColor = isset( $atts['bordercolor'] ) && $atts['bordercolor'] ? 'border-color:' . html_entity_decode( $atts['bordercolor'], ENT_QUOTES, 'UTF-8' ) : 'border-color:inherit'; |
| 55 |
$textColor = isset( $atts['textcolor'] ) && $atts['textcolor'] ? 'color:' . html_entity_decode( $atts['textcolor'], ENT_QUOTES, 'UTF-8' ) : 'color:inherit'; |
| 56 |
$productItemCost = isset( $yaymail_settings['product_item_cost'] ) ? $yaymail_settings['product_item_cost'] : 0; |
| 57 |
?> |
| 58 |
|
| 59 |
<thead class="yaymail_element_head_order_item"> |
| 60 |
<tr style="word-break: normal"> |
| 61 |
<th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_product_title_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_product_title" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>;"> |
| 62 |
<?php esc_html_e( $product_title, 'woocommerce' ); ?> |
| 63 |
</th> |
| 64 |
<?php if ( $productItemCost ) { ?> |
| 65 |
<th class="td yaymail_item_price_per_item" colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_cost_colspan', 1, $yaymail_template ) ); ?>" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>;"> |
| 66 |
<?php esc_html_e( $cost_title, 'woocommerce' ); ?> |
| 67 |
</th> |
| 68 |
<?php } ?> |
| 69 |
<th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_quantity_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_quantity_title" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>;"> |
| 70 |
<?php esc_html_e( $quantity_title, 'woocommerce' ); ?> |
| 71 |
</th> |
| 72 |
<th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_price_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_price_title" scope="col" style="width: 30%;text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>;"> |
| 73 |
<?php esc_html_e( $price_title, 'woocommerce' ); ?> |
| 74 |
</th> |
| 75 |
</tr> |
| 76 |
</thead> |
| 77 |
<tbody class="yaymail_element_body_order_item"> |
| 78 |
<?php |
| 79 |
echo wp_kses_post( |
| 80 |
$this->ordetItemTables( |
| 81 |
$order, |
| 82 |
array( |
| 83 |
'show_sku' => $sent_to_admin, |
| 84 |
'show_image' => false, |
| 85 |
'image_size' => array( 32, 32 ), |
| 86 |
'plain_text' => $plain_text, |
| 87 |
'sent_to_admin' => $sent_to_admin, |
| 88 |
'border_color' => $borderColor, |
| 89 |
'text_color' => $textColor, |
| 90 |
) |
| 91 |
) |
| 92 |
); |
| 93 |
|
| 94 |
?> |
| 95 |
</tbody> |
| 96 |
<tfoot class="yaymail_element_foot_order_item"> |
| 97 |
<?php |
| 98 |
$totalItem = $order->get_order_item_totals(); |
| 99 |
$i = 0; |
| 100 |
foreach ( $totalItem as $key => $total ) { |
| 101 |
$i++; |
| 102 |
$tr_class = ''; |
| 103 |
$th_class = ''; |
| 104 |
if ( array_key_exists( $key, $get_order_item_totals_class ) ) { |
| 105 |
if ( 'refund_0' == $key ) { |
| 106 |
if ( __( 'Order fully refunded.', 'woocommerce' ) == $total['label'] ) { |
| 107 |
$tr_class = esc_attr( $get_order_item_totals_class[ $key ] . '_row' ); |
| 108 |
} |
| 109 |
} else { |
| 110 |
$tr_class = esc_attr( $get_order_item_totals_class[ $key ] . '_row' ); |
| 111 |
} |
| 112 |
} |
| 113 |
if ( array_key_exists( $key, $get_order_item_totals_class ) ) { |
| 114 |
if ( 'refund_0' == $key ) { |
| 115 |
if ( __( 'Order fully refunded.', 'woocommerce' ) == $total['label'] ) { |
| 116 |
$th_class = esc_attr( $get_order_item_totals_class[ $key ] ); |
| 117 |
} |
| 118 |
} else { |
| 119 |
$th_class = esc_attr( $get_order_item_totals_class[ $key ] ); |
| 120 |
} |
| 121 |
} |
| 122 |
?> |
| 123 |
|
| 124 |
<tr class="<?php echo esc_attr( $tr_class ); ?>"> |
| 125 |
<th class="td <?php echo esc_attr( $th_class ); ?>" scope="row" colspan="<?php echo esc_attr( $productItemCost ? 3 : 2 ); ?>" style="text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>; <?php echo esc_attr( ( 1 === $i ) ? 'border-top-width: 4px;' : '' ); ?>"> |
| 126 |
<?php |
| 127 |
if ( array_key_exists( $key, $get_order_item_totals ) ) { |
| 128 |
if ( 'refund_0' == $key ) { |
| 129 |
if ( __( 'Order fully refunded.', 'woocommerce' ) == $total['label'] ) { |
| 130 |
echo esc_html_e( $get_order_item_totals[ $key ], 'woocommerce' ); |
| 131 |
} else { |
| 132 |
echo wp_kses_post( $total['label'] ); |
| 133 |
} |
| 134 |
} else { |
| 135 |
echo esc_html_e( $get_order_item_totals[ $key ], 'woocommerce' ); |
| 136 |
} |
| 137 |
} else { |
| 138 |
echo wp_kses_post( $total['label'] ); |
| 139 |
} |
| 140 |
?> |
| 141 |
</th> |
| 142 |
<th class="td |
| 143 |
<?php |
| 144 |
if ( array_key_exists( $key, $item_content_class ) ) { |
| 145 |
if ( 'refund_0' == $key ) { |
| 146 |
if ( __( 'Order fully refunded.', 'woocommerce' ) == $total['label'] ) { |
| 147 |
echo esc_html( $item_content_class[ $key ] ); |
| 148 |
} |
| 149 |
} else { |
| 150 |
echo esc_html( $item_content_class[ $key ] ); |
| 151 |
} |
| 152 |
} |
| 153 |
?> |
| 154 |
" style="font-weight: normal;text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>; <?php echo esc_attr( ( 1 === $i ) ? 'border-top-width: 4px;' : '' ); ?>"> |
| 155 |
<?php echo wp_kses_post( $total['value'] ); ?> |
| 156 |
</th> |
| 157 |
</tr> |
| 158 |
|
| 159 |
<?php |
| 160 |
} |
| 161 |
|
| 162 |
if ( ! empty( $order->get_customer_note() ) ) { |
| 163 |
$note = $order->get_customer_note(); |
| 164 |
?> |
| 165 |
|
| 166 |
<tr class="yaymail_item_note_title_row"> |
| 167 |
<th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>; <?php echo esc_attr( ( 1 === $i ) ? 'border-top-width: 4px;' : '' ); ?>"> |
| 168 |
<?php esc_html_e( $get_order_item_totals['customer_note'], 'woocommerce' ); ?> |
| 169 |
</th> |
| 170 |
<th class="td" style="font-weight: normal;text-align:<?php echo esc_attr( $text_align ); ?>;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( $borderColor ); ?>; <?php echo esc_attr( ( 1 === $i ) ? 'border-top-width: 4px;' : '' ); ?>"> |
| 171 |
<?php echo esc_html( $note ); ?> |
| 172 |
</th> |
| 173 |
</tr> |
| 174 |
|
| 175 |
<?php } ?> |
| 176 |
</tfoot> |
| 177 |
|