PluginProbe
YayMail – WooCommerce Email Customizer / 3.3.1
YayMail – WooCommerce Email Customizer v3.3.1
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 3.4.1 All 57 releases
yaymail / views / templates / emails / email-order-items-preview.php

email-order-items-preview.php in YayMail – WooCommerce Email Customizer 3.3.1, at views/templates/emails/email-order-items-preview.php

291 lines 15.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6 $text_align = is_rtl() ? 'right' : 'left';
7 $yaymail_settings = get_option( 'yaymail_settings' );
8 $yaymail_template = get_post_meta( $postID, '_yaymail_template', true );
9 $orderImagePostions = isset( $yaymail_settings['image_position'] ) && ! empty( $yaymail_settings['image_position'] ) ? $yaymail_settings['image_position'] : 'Top';
10 $orderImage = isset( $yaymail_settings['product_image'] ) && '0' != $yaymail_settings['product_image'] ? $yaymail_settings['product_image'] : '0';
11 $productHyperLinks = isset( $yaymail_settings['product_hyper_links'] ) ? $yaymail_settings['product_hyper_links'] : 0;
12 $productRegularPrice = isset( $yaymail_settings['product_regular_price'] ) ? $yaymail_settings['product_regular_price'] : 0;
13 $productItemCost = isset( $yaymail_settings['product_item_cost'] ) ? $yaymail_settings['product_item_cost'] : 0;
14
15 if ( ! function_exists( 'yaymail_get_global_taxonomy_attribute_data' ) ) :
16 function yaymail_get_global_taxonomy_attribute_data( $name, $product, $single_product = null ) {
17 $out = array();
18
19 $product_id = is_numeric( $product ) ? $product : $product->get_id();
20 $terms = wp_get_post_terms( $product_id, $name, 'all' );
21
22 if ( ! empty( $terms ) ) {
23 if ( ! is_wp_error( $terms ) ) {
24 $tax = $terms[0]->taxonomy;
25 $tax_object = get_taxonomy( $tax );
26 if ( isset( $tax_object->labels->singular_name ) ) {
27 $out['label'] = $tax_object->labels->singular_name;
28 } elseif ( isset( $tax_object->label ) ) {
29 $out['label'] = $tax_object->label;
30 $label_prefix = __( 'Product', 'woocommerce-show-attributes' ) . ' ';
31 if ( 0 === strpos( $out['label'], $label_prefix ) ) {
32 $out['label'] = substr( $out['label'], strlen( $label_prefix ) );
33 }
34 }
35 $tax_terms = array();
36 foreach ( $terms as $term ) {
37 $single_term = esc_html( $term->name );
38
39 // Show terms as links?
40 if ( $single_product ) {
41 if ( get_option( 'wcsa_terms_as_links' ) == 'yes' ) {
42 $term_link = get_term_link( $term );
43 if ( ! is_wp_error( $term_link ) ) {
44 $single_term = '<a href="' . esc_url( $term_link ) . '">' . esc_html( $term->name ) . '</a>';
45 }
46 }
47 }
48 array_push( $tax_terms, $single_term );
49 }
50 $out['value'] = implode( ', ', $tax_terms );
51 }
52 }
53
54 return $out;
55 }
56 endif;
57
58 foreach ( $items as $item_id => $item ) :
59 if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
60 $product = $item->get_product();
61 $result_attributes = array();
62 $product_id = ( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
63 ?>
64 <?php
65 // For Woo Show Attributes Plugins
66 if ( class_exists( 'WooCommerce_Show_Attributes' ) ) {
67
68 if ( is_a( $product, 'WC_Product_Variation' ) ) {
69 $attributes = get_post_meta( $product->get_parent_id(), '_product_attributes', true );
70 if ( ! $attributes ) {
71 echo '';
72 }
73 foreach ( $attributes as $attribute ) {
74 if ( $attribute['is_visible'] && empty( $attribute['is_variation'] ) ) {
75 if ( $attribute['is_taxonomy'] ) {
76 $result_attributes[] = yaymail_get_global_taxonomy_attribute_data( $attribute['name'], $product->get_parent_id() );
77 } else {
78 $result_attributes[] = array(
79 'label' => $attribute['name'],
80 'value' => $attribute['value'],
81 );
82 }
83 }
84 }
85 } else {
86
87 $attributes = $product->get_attributes();
88 if ( ! $attributes ) {
89 echo '';
90 }
91 foreach ( $attributes as $attribute ) {
92 if ( ! is_a( $attribute, 'WC_Product_Attribute' ) ) {
93 continue;
94 }
95 if ( $attribute->get_variation() ) {
96 continue;
97 }
98 if ( ! $attribute->get_visible() ) {
99 continue;
100 }
101 $name = $attribute->get_name();
102 if ( $attribute->is_taxonomy() ) {
103 $result_attributes[] = yaymail_get_global_taxonomy_attribute_data( $name, $product );
104 } else {
105 $result_attributes[] = array(
106 'label' => $name,
107 'value' => esc_html( implode( ', ', $attribute->get_options() ) ),
108 );
109
110 }
111 }
112 }
113 }
114 ?>
115 <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
116 <th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_product_title_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_product_content" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal;word-wrap:break-word;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;">
117 <?php
118
119 if ( 'Bottom' == $orderImagePostions && '1' == $orderImage ) {
120 echo ( '<div class="yaymail-product-texts preview1" style="padding: 5px 0;">' );
121 // Product name
122 if ( $productHyperLinks ) {
123 if ( method_exists( $product, 'get_permalink' ) ) {
124 echo wp_kses_post( ' <a style="color:' . $text_link_color . '" target="_blank" href="' . $product->get_permalink() . '"><span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span></a>' );
125 } else {
126 echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' );
127 }
128 } else {
129 echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' );
130 }
131
132 // SKU
133 if ( $args['show_sku'] && is_object( $product ) && $product->get_sku() && $product ) {
134 echo wp_kses_post( '<span class="yaymail-product-sku"> (#' . $product->get_sku() . ')</span>' );
135 }
136
137 if ( $args['show_des'] && is_object( $product ) && $product->get_short_description() && $product ) {
138 echo wp_kses_post( '<div class="yaymail-product-short-descript"> (#' . $product->get_short_description() . ')</div>' );
139 }
140 if ( $args['show_des'] && is_object( $product ) && 'variation' === $product->get_type() ) {
141 echo wp_kses_post( '<div class="yaymail-product-description"> (#' . $product->get_description() . ')</div>' );
142 }
143
144 // Woo Show Attributes
145 if ( class_exists( 'WooCommerce_Show_Attributes' ) ) :
146 foreach ( $result_attributes as $key1 => $result_attribute ) {
147 $attribute_output = $result_attribute['label'] . ': ' . $result_attribute['value'];
148 echo '<br>' . wp_kses_post( $attribute_output );
149 }
150 endif;
151 // allow other plugins to add additional product information here
152 do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $args['plain_text'] );
153 if ( class_exists( 'YITH_Barcode' ) ) {
154 if ( YITH_YWBC()->show_product_barcode_on_email ) {
155 echo '<div class="ywbc-email-product-barcode-container">' . do_shortcode( '[yith_render_barcode id="' . $product_id . '"]' ) . '</div>';
156 }
157 }
158
159 // Display item meta data.
160 wc_display_item_meta( $item );
161
162 echo ( '</div>' );
163 // Show title/image etc
164 if ( $args['show_image'] && is_object( $product ) ) {
165 echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', '<div class="yaymail-product-image" style="margin-bottom: 5px"><img src="' . ( $product->get_image_id() ? current( wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] ) ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( str_replace( 'px', '', $args['image_size'][1] ) ) . '" width="' . esc_attr( str_replace( 'px', '', $args['image_size'][0] ) ) . '" style="vertical-align:middle; margin-' . ( is_rtl() ? 'left' : 'right' ) . ': 10px;" /></div>', $item ) );
166 }
167 } else {
168 // Show title/image etc
169 if ( $args['show_image'] && is_object( $product ) ) {
170 if ( 'Top' == $orderImagePostions && $args['show_image'] && is_object( $product ) ) {
171 echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', '<div class="yaymail-product-image" style="margin-bottom: 5px; float: unset"><img src="' . ( $product->get_image_id() ? current( wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] ) ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( str_replace( 'px', '', $args['image_size'][1] ) ) . '" width="' . esc_attr( str_replace( 'px', '', $args['image_size'][0] ) ) . '" style="vertical-align:middle; margin-' . ( is_rtl() ? 'left' : 'right' ) . ': 10px;" /></div>', $item ) );
172 } else {
173 echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', '<div class="yaymail-product-image" style="margin-bottom: 5px; float: left"><img src="' . ( $product->get_image_id() ? current( wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] ) ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( str_replace( 'px', '', $args['image_size'][1] ) ) . '" width="' . esc_attr( str_replace( 'px', '', $args['image_size'][0] ) ) . '" style="vertical-align:middle; margin-' . ( is_rtl() ? 'left' : 'right' ) . ': 10px;" /></div>', $item ) );
174 }
175 }
176 echo ( '<div class="yaymail-product-texts" style="padding: 5px 0;">' );
177 // Product name
178 if ( $productHyperLinks ) {
179 if ( method_exists( $product, 'get_permalink' ) ) {
180 echo wp_kses_post( ' <a style="color:' . $text_link_color . '" target="_blank" href="' . $product->get_permalink() . '"><span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span></a>' );
181 } else {
182 echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' );
183 }
184 } else {
185 echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' );
186 }
187
188
189 // SKU
190 if ( $args['show_sku'] && is_object( $product ) && $product->get_sku() && $product ) {
191 echo wp_kses_post( '<span class="yaymail-product-sku"> (#' . $product->get_sku() . ')</span>' );
192 }
193
194 if ( $args['show_des'] && is_object( $product ) && $product->get_short_description() && $product ) {
195 echo wp_kses_post( '<div class="yaymail-product-short-descript"> (#' . $product->get_short_description() . ')</div>' );
196 }
197 if ( $args['show_des'] && is_object( $product ) && 'variation' === $product->get_type() ) {
198 echo wp_kses_post( '<div class="yaymail-product-description"> (#' . $product->get_description() . ')</div>' );
199 }
200 if ( class_exists( 'WooCommerce_Show_Attributes' ) ) :
201 foreach ( $result_attributes as $key1 => $result_attribute ) {
202 $attribute_output = $result_attribute['label'] . ': ' . $result_attribute['value'];
203 echo '<br>' . wp_kses_post( $attribute_output );
204 }
205 endif;
206 // allow other plugins to add additional product information here
207 do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $args['plain_text'] );
208 if ( class_exists( 'YITH_Barcode' ) ) {
209 if ( YITH_YWBC()->show_product_barcode_on_email ) {
210 echo '<div class="ywbc-email-product-barcode-container">' . do_shortcode( '[yith_render_barcode id="' . $product_id . '"]' ) . '</div>';
211 }
212 }
213
214 // Display item meta data.
215 wc_display_item_meta( $item );
216
217 echo ( '</div>' );
218 }
219
220
221 // Display item download links.
222 if ( $args['show_download_links'] ) {
223 wc_display_item_downloads( $item );
224 }
225
226 // allow other plugins to add additional product information here
227 do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $args['plain_text'] );
228 ?>
229
230 </th>
231 <?php if ( $productItemCost && is_object( $product ) ) { ?>
232 <th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_cost_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_cost_content" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal; vertical-align:middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;">
233 <?php echo wp_kses_post( wc_price( $order->get_item_subtotal( $item, false, true ), array( 'currency' => $order->get_currency() ) ) ); ?>
234 </th>
235 <?php } ?>
236 <th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_quantity_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_quantity_content" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal; vertical-align:middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;">
237 <?php
238 $qty = $item->get_quantity();
239 $refunded_qty = $order->get_qty_refunded_for_item( $item_id );
240
241 if ( $refunded_qty && 'customer_refunded_order' == $yaymail_template ) {
242 $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
243 } else {
244 $qty_display = esc_html( $qty );
245 }
246 echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ) );
247 ?>
248 </th>
249 <th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_price_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_price_content" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>; word-break: break-all;">
250 <?php
251 if ( $productRegularPrice && is_object( $product ) ) {
252 $product_regular_price = isset( $product->get_data()['regular_price'] ) ? (float) $product->get_data()['regular_price'] : null;
253 if ( (float) $product_regular_price !== $order->get_line_subtotal( $item, true ) ) {
254 echo wp_kses_post( '<del>' . wc_price( $product_regular_price ) . '</del> ' );
255 }
256 } echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) );
257 ?>
258 </th>
259 </tr>
260 <?php
261 }
262
263 // Show purchase note
264 $purchase_note = '';
265 if ( $product && $product->get_purchase_note() ) {
266 $purchase_note = $product->get_purchase_note();
267 }
268
269 if ( ( 'customer_on_hold_order' === $this->template
270 || 'customer_processing_order' === $this->template
271 || 'customer_completed_order' === $this->template
272 || 'customer_refunded_order' === $this->template
273 || 'customer_invoice' === $this->template
274 || 'customer_note' === $this->template
275 || 'new_order' === $this->template )
276 && isset( $args['show_purchase_note'] )
277 && is_object( $product )
278 && ! empty( $purchase_note )
279 ) {
280 ?>
281
282 <tr class="yaymail-purchase-note">
283 <th colspan="3" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;">
284 <?php echo wp_kses_post( wpautop( do_shortcode( $purchase_note ) ) ); ?>
285 </th>
286 </tr>
287
288 <?php } ?>
289
290 <?php endforeach; ?>
291