/var/www/html_it/wp-content/plugins/yaymail/templates/shortcodes/order-details/order-items/main.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php

defined
'ABSPATH' ) || exit;

use 
YayMail\Utils\TemplateHelpers;

$text_align  yaymail_get_text_align();
$margin_side is_rtl() ? 'left' 'right';
$order_id    = isset( $args['order'] ) ? $args['order']->get_id() : '';
$order_data  = isset( $order_id ) ? wc_get_order$order_id ) : '';

if ( empty( 
$order_data ) ) {
    
$order_data = isset( $args['order'] ) ? $args['order'] : null;
}

$element_data       = isset( $args['element'] ) ? $args['element'] : [];
$border_color       = isset( $element_data['border_color'] ) ? $element_data['border_color'] : 'inherit';
$text_style         = isset( $args['text_style'] ) ? $args['text_style'] : '';
$image_style        = isset( $args['styles_product_image'] ) ? $args['styles_product_image'] : '';
$is_placeholder     = isset( $args['is_placeholder'] ) ? $args['is_placeholder'] : false;
$structure_items    = isset( $args['structure_items'] ) ? $args['structure_items'] : [];
$yaymail_settings   yaymail_settings();
$order_items        = ! empty( $order_data ) ? $order_data->get_items() : [];
$image_height       = isset( $yaymail_settings['product_image_height'] ) ? $yaymail_settings['product_image_height'] : '30';
$image_width        = isset( $yaymail_settings['product_image_width'] ) ? $yaymail_settings['product_image_width'] : '30';
$image_position     = isset( $yaymail_settings['product_image_position'] ) ? $yaymail_settings['product_image_position'] : 'top';
$show_image         = isset( $yaymail_settings['show_product_image'] ) ? boolval$yaymail_settings['show_product_image'] ) : false;
$show_sku           = isset( $yaymail_settings['show_product_sku'] ) ? boolval$yaymail_settings['show_product_sku'] ) : false;
$show_des           = isset( $yaymail_settings['show_product_description'] ) ? boolval$yaymail_settings['show_product_description'] ) : false;
$show_hyper_links   = isset( $yaymail_settings['show_product_hyper_links'] ) ? boolval$yaymail_settings['show_product_hyper_links'] ) : false;
$show_regular_price = isset( $yaymail_settings['show_product_regular_price'] ) ? boolval$yaymail_settings['show_product_regular_price'] ) : false;

$show_purchase_note true;
$purchase_note      true;

$is_layout_type_modern = isset( $element_data['layout_type'] ) && 'modern' === $element_data['layout_type'];

foreach ( 
$order_items as $item_id => $item ) :
    
$product               $item->get_product();
    
$sku                   '';
    
$purchase_note         '';
    
$image_url             wc_placeholder_img_src();
    
$image                 $is_placeholder "<img width='{{product_image_width}}px' height='{{product_image_height}}px' src='{$image_url}' alt='product image'/>" "<img width='{$image_width}px' height='{$image_height}px' src='{$image_url}' alt='product image'/>";
    
$short_description     '';
    
$product_name          $item->get_name();
    
$product_permalink     '#';
    
$product_hyper_link    "<a href='{$product_permalink}' target='_blank'>{$product_name}</a>";
    
$product_regular_price '';

    if ( ! 
apply_filters'woocommerce_order_item_visible'true$item ) ) {
        continue;
    }

    if ( 
is_object$product ) ) {
        
$sku                   $product->get_sku();
        
$purchase_note         $product->get_purchase_note();
        
$image_url             currentwp_get_attachment_image_src$product->get_image_id(), 'full' ) ? wp_get_attachment_image_src$product->get_image_id(), 'full' ) : [] );
        
$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'/>";
        
$short_description     $product->get_short_description();
        
$product_permalink     method_exists$product'get_permalink' ) ? $product->get_permalink() : '#';
        
$product_hyper_link    "<a href='{$product_permalink}' target='_blank'>{$product_name}</a>";
        
$product_regular_price = isset( $product->get_data()['regular_price'] ) ? (float) $product->get_data()['regular_price'] : '';
    }
    
?>
   
    <tr class="<?php echo esc_attrapply_filters'woocommerce_order_item_class''order_item'$item$order_data ) ); ?>" style="<?php echo esc_attr$text_style ); ?>;">
        <?php
        
foreach ( $structure_items as $key => $structure_item ) :
            if ( isset( 
$structure_item['width'] ) ) {
                
$width 'width: ' $structure_item['width'] . ';';
            } else {
                
$width '';
            }
            
$item_style = isset( $structure_item['style'] ) ? $structure_item['style'] : [];
            if ( ! empty( 
$item_style ) ) {
                
$item_style_string TemplateHelpers::get_style$item_style );
            } else {
                
$item_style_string '';
            }

            
$column_style $text_style $width $item_style_string;
            
?>
            <td colspan="<?php echo esc_attr$structure_item['col_span'] ); ?>" class="td yaymail_item_<?php echo esc_attr$key ); ?>_content" style="<?php echo esc_attr$column_style ); ?>">
            <?php
            
switch ( $key ) :
                case 
'product':
                    
// Show title/image etc.
                    
if ( $show_image && 'bottom' !== $image_position || $is_placeholder ) {
                        echo 
wp_kses_post"<div class='yaymail-product_image_position__top' style='{$image_style}'>" );
                        require 
YAYMAIL_PLUGIN_PATH 'templates/shortcodes/order-details/order-items/image-content.php';
                        echo ( 
'</div>' );
                    }
                    
?>

                    <!-- Product details -->
                    <div class='yaymail-product-details'>
                    <?php

                    
// Product name.
                    
require YAYMAIL_PLUGIN_PATH 'templates/shortcodes/order-details/order-items/product-name-content.php';

                    
// SKU.
                    
if ( ( $show_sku && ! empty( $sku ) ) || ( $is_placeholder && ! empty( $sku ) ) ) {
                        require 
YAYMAIL_PLUGIN_PATH 'templates/shortcodes/order-details/order-items/sku-content.php';
                    }

                    
// Product Description.
                    
if ( ( $show_des && ! empty( $short_description ) ) || ( $is_placeholder && ! empty( $short_description ) ) ) {
                        require 
YAYMAIL_PLUGIN_PATH 'templates/shortcodes/order-details/order-items/product-short-description-content.php';
                    }

                    
// allow other plugins to add additional product information here.
                    
do_action'woocommerce_order_item_meta_start'$item_id$item$order_data'' );
                    
?>
                    <div class="yaymail-wc-item-meta" style="clear:both">
                    <?php
                        wc_display_item_meta
(
                            
$item,
                            [
                                
'label_before' => '<strong class="wc-item-meta-label yaymail-item-meta-label" style="float: ' esc_attr$text_align ) . '; margin-' esc_attr$margin_side ) . ': .25em; clear: both">',
                            ]
                        );
                    
?>
                    </div>
                    <?php

                    
// allow other plugins to add additional product information here.
                    
do_action'woocommerce_order_item_meta_end'$item_id$item$order_data'' );

                    
// Show title/image etc in bottom.
                    
if ( ( $show_image && 'bottom' === $image_position ) || $is_placeholder ) {
                        echo 
wp_kses_post"<div class='yaymail-product_image_position__bottom' style='{$image_style}'>" );
                        require 
YAYMAIL_PLUGIN_PATH 'templates/shortcodes/order-details/order-items/image-content.php';
                        echo ( 
'</div>' );
                    }
                    
?>
                    </div>
                    <!-- End Product details -->
                    <?php
                    
break;
                case 
'cost':
                    echo 
wp_kses_postwc_price$order_data->get_item_subtotal$itemfalsetrue ), [ 'currency' => $order_data->get_currency() ] ) );
                    break;
                case 
'quantity':
                    
$qty          $item->get_quantity();
                    
$refunded_qty $order_data->get_qty_refunded_for_item$item_id );

                    if ( 
$refunded_qty ) {
                        
$qty_display '<del>' esc_html$qty ) . '</del> <ins>' esc_html$qty - ( $refunded_qty * -) ) . '</ins>';
                    } else {
                        
$qty_display esc_html$qty );
                    }
                    
?>
                    <?php if ( $is_layout_type_modern || $is_placeholder ) : ?>
                        <span class="yaymail-quantity-type-modern">x</span>
                    <?php endif; ?>
                    <?php
                    
echo wp_kses_postapply_filters'woocommerce_email_order_item_quantity'$qty_display$item ) );
                    break;
                case 
'price':
                    
// Show product regular price.
                    
if ( ( $show_regular_price && ! empty( $product_regular_price ) ) || ( $is_placeholder && ! empty( $product_regular_price ) ) ) {
                        require 
YAYMAIL_PLUGIN_PATH 'templates/shortcodes/order-details/order-items/product-regular-price-content.php';
                    }
                        echo 
wp_kses_post$order_data->get_formatted_line_subtotal$item ) );
                    break;
                default:
                    echo 
wp_kses_postdo_action'yaymail_order_details_item_' $key '_content'$item$order_data$element_datafalse ) );
                    break;
            endswitch;
            
?>
            </td>
        <?php endforeach; ?>
    </tr>
    <?php

    
if ( $show_purchase_note && $purchase_note ) {
        
?>
        <tr>
            <td class="yaymail-purchase-note" colspan="<?php echo isset( $structure_items['cost'] ) ? 2?>" style="<?php echo esc_attr$text_style ); ?>;">
                <?php
                
echo wp_kses_postwpautopdo_shortcode$purchase_note ) ) );
                
?>
            </td>
        </tr>
        <?php
    
}
    
?>

<?php endforeach; ?>