PluginProbe
YayMail – WooCommerce Email Customizer / 3.2.2
YayMail – WooCommerce Email Customizer v3.2.2
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 3.4.2 3.4.3 All 55 releases
yaymail / includes / MailBuilder / Shortcodes.php

Shortcodes.php in YayMail – WooCommerce Email Customizer 3.2.2, at includes/MailBuilder/Shortcodes.php

1,909 lines 89.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\MailBuilder;
4
5 use YayMail\Helper\Helper;
6 use YayMail\Page\Source\CustomPostType;
7 use YayMail\Page\Source\UpdateElement;
8 use YayMail\Templates\Templates;
9 use YayMail\Helper\WooLatepoint;
10
11 defined( 'ABSPATH' ) || exit;
12 global $woocommerce, $wpdb, $current_user, $order;
13
14 class Shortcodes {
15
16 protected static $instance = null;
17 public $order_id = false;
18
19 public $order;
20 public $sent_to_admin = false;
21 public $order_data;
22 public $template = false;
23 public $customer_note = false;
24 public $shipping_address = null;
25 public $billing_address = null;
26 public $preview_mail = false;
27 public $args_email = array();
28
29 // public $array_content_template = false;
30 public $shortcodes_lists;
31 public static function getInstance() {
32 if ( null == self::$instance ) {
33 self::$instance = new self();
34 }
35 return self::$instance;
36 }
37
38 public function __construct( $template = false, $checkOrder = '', $preview_mail = true ) {
39 $this->preview_mail = $preview_mail;
40 if ( $template ) {
41 $this->template = $template;
42 if ( 'sampleOrder' === $checkOrder ) {
43 $this->shortCodesOrderSample();
44 } else {
45 $this->shortCodesOrderDefined();
46 }
47 // style css
48 add_filter( 'woocommerce_email_styles', array( $this, 'customCss' ) );
49
50 add_filter( 'safe_style_css', array( $this, 'filter_safe_style_css' ), 10, 1 );
51
52 // Order Details
53 $order_details_list = array(
54 'items_downloadable_title',
55 'items_downloadable_product',
56 'items_border',
57 'items',
58 'items_products_quantity_price',
59 'order_date',
60 'order_fee',
61 'order_id',
62 'order_link',
63 'order_link_string',
64 'order_number',
65 'order_refund',
66 'order_sub_total',
67 'order_discount',
68 'order_total',
69 'order_total_numbers',
70 'orders_count',
71 'quantity_count',
72 'orders_count_double',
73 'order_tn',
74 'items_border_before',
75 'items_border_after',
76 'items_border_title',
77 'items_border_content',
78 'items_downloadable_product',
79 'items_downloadable_title',
80 'get_heading',
81 'woocommerce_email_order_meta',
82 'woocommerce_email_order_details',
83 'woocommerce_email_before_order_table',
84 'woocommerce_email_after_order_table',
85 );
86
87 // Payments
88 $payments_list = array(
89 'order_payment_method',
90 'order_payment_url',
91 'order_payment_url_string',
92 'payment_instruction',
93 'payment_method',
94 'transaction_id',
95 );
96
97 // Shippings
98 $shippings_list = array(
99 'order_shipping',
100 'shipping_address',
101 'shipping_address_1',
102 'shipping_address_2',
103 'shipping_city',
104 'shipping_company',
105 'shipping_country',
106 'shipping_first_name',
107 'shipping_last_name',
108 'shipping_method',
109 'shipping_postcode',
110 'shipping_state',
111 'shipping_phone',
112 );
113
114 // Billings
115 $billings_list = array(
116 'billing_address',
117 'billing_address_1',
118 'billing_address_2',
119 'billing_city',
120 'billing_company',
121 'billing_country',
122 'billing_email',
123 'billing_first_name',
124 'billing_last_name',
125 'billing_phone',
126 'billing_postcode',
127 'billing_state',
128 );
129
130 // Reset Password
131 $reset_password_list = array( 'password_reset_url', 'password_reset_url_string', 'wp_password_reset_url' );
132
133 // New Users
134 $new_users_list = array( 'user_new_password', 'user_activation_link', 'set_password_url_string' );
135
136 // General
137 $general_list = array(
138 'customer_note',
139 'customer_notes',
140 'customer_provided_note',
141 'site_name',
142 'site_url',
143 'site_url_string',
144 'user_email',
145 'user_id',
146 'user_name',
147 'customer_username',
148 'customer_roles',
149 'additional_content',
150 'customer_name',
151 'customer_first_name',
152 'customer_last_name',
153 'view_order_url',
154 'view_order_url_string',
155 'billing_shipping_address',
156 'domain',
157 'user_account_url',
158 'user_account_url_string',
159 //new
160 'billing_shipping_address_title',
161 'billing_shipping_address_content',
162 'check_billing_shipping_address',
163 'order_coupon_codes',
164
165 );
166 //WooCommerce for LatePoint
167 $woo_latepoint = array(
168 'woo_latepoint_booking_detail',
169 'woo_latepoint_calendar_start_date',
170 'woo_latepoint_selected_total_attendees',
171 'woo_latepoint_caption',
172 'woo_latepoint_bg_color',
173 'woo_latepoint_text_color',
174 'woo_latepoint_font_size',
175 'woo_latepoint_border',
176 'woo_latepoint_border_radius',
177 'woo_latepoint_margin',
178 'woo_latepoint_padding',
179 'woo_latepoint_css',
180 'woo_latepoint_show_locations',
181 'woo_latepoint_show_agents',
182 'woo_latepoint_show_services',
183 'woo_latepoint_show_service_categories',
184 'woo_latepoint_selected_location',
185 'woo_latepoint_selected_agent',
186 'woo_latepoint_selected_service',
187 'woo_latepoint_selected_service_category',
188 'woo_latepoint_selected_duration',
189 'woo_latepoint_hide_side_panel',
190 'woo_latepoint_hide_summary',
191 );
192
193 // Additional Order Meta.
194 $order = CustomPostType::getListOrders();
195
196 /* Define Shortcodes */
197 $shortcodes_lists = array();
198 $arrShortcodeCustoms = array();
199 $shortcode = array();
200 $yaymail_informations = Helper::inforShortcode( '', $template, array() );
201 $shortcodeCustom = array_keys( apply_filters( 'yaymail_customs_shortcode', $shortcode, $yaymail_informations, $this->args_email ) );
202
203 if ( ! empty( $shortcodeCustom ) ) {
204 foreach ( $shortcodeCustom as $item ) {
205 array_push( $arrShortcodeCustoms, str_replace( array( '[', ']' ), '', $item ) );
206 }
207 $shortcodes_lists = array_merge( $shortcodes_lists, $arrShortcodeCustoms );
208 }
209
210 $shortcodes_lists = array_merge( $shortcodes_lists, apply_filters( 'yaymail_shortcodes', $shortcodes_lists ) );
211 $shortcodes_lists = array_merge( $shortcodes_lists, $order_details_list );
212 $shortcodes_lists = array_merge( $shortcodes_lists, $payments_list );
213 $shortcodes_lists = array_merge( $shortcodes_lists, $shippings_list );
214 $shortcodes_lists = array_merge( $shortcodes_lists, $billings_list );
215 $shortcodes_lists = array_merge( $shortcodes_lists, $reset_password_list );
216 $shortcodes_lists = array_merge( $shortcodes_lists, $new_users_list );
217 $shortcodes_lists = array_merge( $shortcodes_lists, $general_list );
218 $shortcodes_lists = array_merge( $shortcodes_lists, $woo_latepoint );
219 $this->shortcodes_lists = $shortcodes_lists;
220 foreach ( $this->shortcodes_lists as $key => $shortcode_name ) {
221 if ( 'woocommerce_email_before_order_table' == $shortcode_name || 'woocommerce_email_after_order_table' == $shortcode_name || 'woocommerce_email_order_details' == $shortcode_name || 'woocommerce_email_order_meta' == $shortcode_name ) {
222 $function_name = $this->parseShortCodeToFunctionName( 'woocomme' . $shortcode_name );
223 if ( method_exists( $this, $function_name ) ) {
224 add_shortcode(
225 $shortcode_name,
226 function ( $atts, $content, $tag ) {
227 $function_name = $this->parseShortCodeToFunctionName( 'woocomme' . $tag );
228 return $this->$function_name( $atts, $this->order, $this->sent_to_admin, $this->args_email );
229 }
230 );
231 }
232 } else {
233 $function_name = $this->parseShortCodeToFunctionName( 'yaymail_' . $shortcode_name );
234 if ( method_exists( $this, $function_name ) || method_exists( WooLatepoint::class, $function_name ) ) {
235 if ( str_contains( $shortcode_name, 'woo_latepoint' ) ) {
236 add_shortcode(
237 'yaymail_' . $shortcode_name,
238 function ( $atts, $content, $tag ) {
239 $function_name = $this->parseShortCodeToFunctionName( $tag );
240 return WooLatepoint::$function_name( $atts, $this->order, $this->sent_to_admin, $this->args_email );
241 }
242 );
243 } else {
244 add_shortcode(
245 'yaymail_' . $shortcode_name,
246 function ( $atts, $content, $tag ) {
247 $function_name = $this->parseShortCodeToFunctionName( $tag );
248 return $this->$function_name( $atts, $this->order, $this->sent_to_admin, $this->args_email );
249 }
250 );
251 }
252 } elseif ( strpos( $shortcode_name, 'addon' ) !== false || strpos( $shortcode_name, 'custom_shortcode' ) !== false ) {
253 add_shortcode(
254 $shortcode_name,
255 function ( $atts, $content, $tag ) {
256 return $this->order_data[ '[' . $tag . ']' ];
257 }
258 );
259 } else {
260 add_shortcode( 'yaymail_' . $shortcode_name, array( $this, 'shortcodeCallBack' ) );
261 }
262 }
263 }
264 }
265 }
266
267 public function parseShortCodeToFunctionName( $shortcode_name ) {
268 $function_name = substr( $shortcode_name, 8 );
269 $offset = 0;
270 while ( false !== strpos( $function_name, '_', $offset ) ) {
271 $position = strpos( $function_name, '_', $offset );
272 $function_name[ $position + 1 ] = strtoupper( $function_name[ $position + 1 ] );
273 $offset = $position + 1;
274 }
275 $function_name = str_replace( '_', '', $function_name );
276 return $function_name;
277 }
278
279 public function applyCSSFormat( $defaultsCss = '' ) {
280 $templateEmail = \YayMail\Templates\Templates::getInstance();
281 $css = $templateEmail::getCssFortmat();
282 $cssDirection = '';
283 $cssDirection .= 'td{direction: rtl}';
284 $cssDirection .= 'td, th, td{text-align:right;}';
285
286 $css .= get_option( 'yaymail_direction' ) && get_option( 'yaymail_direction' ) === 'rtl' ? $cssDirection : '';
287 $css .= $defaultsCss;
288 $css .= '.td { color: inherit; }';
289 return $css;
290 }
291 public function customCss( $css = '' ) {
292 return $this->applyCSSFormat( $css );
293 }
294
295 public function filter_safe_style_css( $array ) {
296 if ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'wp-social-reviews/wp-social-reviews.php' ) ) {
297 $style_css = array(
298 'background',
299 'background-color',
300 'border',
301 'border-width',
302 'border-color',
303 'border-style',
304 'border-right',
305 'border-right-color',
306 'border-right-style',
307 'border-right-width',
308 'border-bottom',
309 'border-bottom-color',
310 'border-bottom-style',
311 'border-bottom-width',
312 'border-left',
313 'border-left-color',
314 'border-left-style',
315 'border-left-width',
316 'border-top',
317 'border-top-color',
318 'border-top-style',
319 'border-top-width',
320 'border-spacing',
321 'border-collapse',
322 'caption-side',
323 'color',
324 'font',
325 'font-family',
326 'font-size',
327 'font-style',
328 'font-variant',
329 'font-weight',
330 'letter-spacing',
331 'line-height',
332 'text-decoration',
333 'text-indent',
334 'text-align',
335 'height',
336 'min-height',
337 'max-height',
338 'width',
339 'min-width',
340 'max-width',
341 'margin',
342 'margin-right',
343 'margin-bottom',
344 'margin-left',
345 'margin-top',
346 'padding',
347 'padding-right',
348 'padding-bottom',
349 'padding-left',
350 'padding-top',
351 'clear',
352 'cursor',
353 'direction',
354 'float',
355 'overflow',
356 'vertical-align',
357 'list-style-type',
358 );
359 return $style_css;
360 } else {
361 return $array;
362 }
363
364 }
365
366 public function setOrderId( $order_id = '', $sent_to_admin = '', $args = '' ) {
367 $this->order_id = $order_id;
368 $this->args_email = $args;
369 $this->sent_to_admin = $sent_to_admin;
370 // Additional Order Meta.
371 $order_meta_list = array();
372 if ( ! empty( $this->order_id ) ) {
373 $order_metaArr = get_post_meta( $this->order_id );
374 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
375 foreach ( $order_metaArr as $k => $v ) {
376 $nameField = str_replace( ' ', '_', trim( $k ) );
377 $order_meta_list[] = 'order_meta:' . $nameField;
378 }
379 }
380 }
381 $shortcodes_lists = array();
382 $shortcodes_lists = array_merge( $shortcodes_lists, $order_meta_list );
383 $order = wc_get_order( $order_id );
384 $shortcode_order_taxes = array();
385 if ( ! empty( $order ) ) {
386 foreach ( $order->get_items( 'tax' ) as $item_id => $item_tax ) {
387 $tax_rate_id = $item_tax->get_rate_id();
388 $shortcode_order_taxes[] = 'order_taxes_' . $tax_rate_id;
389 }
390 $shortcodes_lists = array_merge( $shortcodes_lists, $shortcode_order_taxes );
391 }
392
393 foreach ( $shortcodes_lists as $key => $shortcode_name ) {
394 add_shortcode( 'yaymail_' . $shortcode_name, array( $this, 'shortcodeCallBack' ) );
395 }
396 }
397
398 protected function _shortcode_atts( $defaults = array(), $atts = array() ) {
399 if ( isset( $atts['class'] ) ) {
400 $atts['classname'] = $atts['class'];
401 }
402
403 return \shortcode_atts( $defaults, $atts );
404 }
405
406 // short Codes Order when select SampleOrder
407 public function shortCodesOrderSample( $sent_to_admin = '' ) {
408 $user = wp_get_current_user();
409 $useId = get_current_user_id();
410 $this->defaultSampleOrderData( $sent_to_admin );
411 }
412
413 public function shortCodesOrderDefined( $sent_to_admin = '', $args = array() ) {
414 if ( false !== $this->order_id && ! empty( $this->order_id ) && class_exists( 'WC_Order' ) ) {
415 $this->order = new \WC_Order( $this->order_id );
416 $this->collectOrderData( $sent_to_admin, $args );
417 }
418 if ( ! function_exists( 'get_user_by' ) ) {
419 return false;
420 }
421 $action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : '';
422 if ( empty( $this->order_id ) || ! $this->order_id ) {
423 $shortcode = $this->order_data;
424
425 if ( isset( $args['additional_content'] ) ) {
426 $shortcode['[yaymail_additional_content]'] = wp_kses_post( wpautop( wptexturize( $args['additional_content'] ) ) );
427 }
428 if ( isset( $_REQUEST['billing_email'] ) ) {
429 $shortcode['[yaymail_user_email]'] = sanitize_email( $_REQUEST['billing_email'] );
430 $user = get_user_by( 'email', sanitize_email( $_REQUEST['billing_email'] ) );
431 if ( ! empty( $user ) ) {
432 $shortcode['[yaymail_customer_username]'] = $user->user_login;
433 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
434 $shortcode['[yaymail_customer_first_name]'] = get_user_meta( $user->ID, 'first_name', true );
435 $shortcode['[yaymail_customer_last_name]'] = get_user_meta( $user->ID, 'last_name', true );
436 $shortcode['[yaymail_user_id]'] = $user->ID;
437 }
438 }
439 if ( empty( $shortcode['[yaymail_customer_username]'] ) ) {
440 if ( isset( $_REQUEST['user_email'] ) ) {
441 $user = get_user_by( 'email', sanitize_email( $_REQUEST['user_email'] ) );
442 if ( isset( $user->user_login ) ) {
443 $shortcode['[yaymail_customer_username]'] = $user->user_login;
444 }
445 if ( isset( $user->ID ) ) {
446 $shortcode['[yaymail_user_id]'] = $user->ID;
447 }
448 } elseif ( isset( $_REQUEST['email'] ) ) {
449 $user = get_user_by( 'email', sanitize_email( $_REQUEST['email'] ) );
450 if ( isset( $user->user_login ) ) {
451 $shortcode['[yaymail_customer_username]'] = $user->user_login;
452 }
453 if ( isset( $user->ID ) ) {
454 $shortcode['[yaymail_user_id]'] = $user->ID;
455 }
456 }
457 }
458 if ( empty( $shortcode['[yaymail_user_email]'] ) ) {
459 if ( isset( $_REQUEST['user_email'] ) ) {
460 $user = get_user_by( 'email', sanitize_email( $_REQUEST['user_email'] ) );
461 if ( isset( $user->user_email ) ) {
462 $shortcode['[yaymail_user_email]'] = $user->user_email;
463 }
464 if ( isset( $user->ID ) ) {
465 $shortcode['[yaymail_user_id]'] = $user->ID;
466 }
467 } elseif ( isset( $_REQUEST['email'] ) ) {
468 $user = get_user_by( 'email', sanitize_email( $_REQUEST['email'] ) );
469 if ( isset( $user->user_email ) ) {
470 $shortcode['[yaymail_user_email]'] = $user->user_email;
471 }
472 if ( isset( $user->ID ) ) {
473 $shortcode['[yaymail_user_id]'] = $user->ID;
474 }
475 }
476 }
477 if ( empty( $shortcode['[yaymail_customer_name]'] ) ) {
478 if ( isset( $_REQUEST['user_email'] ) ) {
479 $user = get_user_by( 'email', sanitize_email( $_REQUEST['user_email'] ) );
480 if ( isset( $user->user_email ) ) {
481 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
482 $shortcode['[yaymail_customer_first_name]'] = get_user_meta( $user->ID, 'first_name', true );
483 $shortcode['[yaymail_customer_last_name]'] = get_user_meta( $user->ID, 'last_name', true );
484 }
485 if ( isset( $user->ID ) ) {
486 $shortcode['[yaymail_user_id]'] = $user->ID;
487 }
488 } elseif ( isset( $_REQUEST['email'] ) ) {
489 $user = get_user_by( 'email', sanitize_email( $_REQUEST['email'] ) );
490 if ( isset( $user->user_email ) ) {
491 if ( ! empty( get_user_meta( $user->ID, 'first_name', true ) ) && ! empty( get_user_meta( $user->ID, 'last_name', true ) ) ) {
492 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
493 $shortcode['[yaymail_customer_first_name]'] = get_user_meta( $user->ID, 'first_name', true );
494 $shortcode['[yaymail_customer_last_name]'] = get_user_meta( $user->ID, 'last_name', true );
495 } elseif ( isset( $_REQUEST['first_name'] ) && isset( $_REQUEST['last_name'] ) ) {
496 $shortcode['[yaymail_customer_name]'] = sanitize_text_field( $_REQUEST['first_name'] ) . ' ' . sanitize_text_field( $_REQUEST['last_name'] );
497 $shortcode['[yaymail_customer_first_name]'] = sanitize_text_field( $_REQUEST['first_name'] );
498 $shortcode['[yaymail_customer_last_name]'] = sanitize_text_field( $_REQUEST['last_name'] );
499 }
500 }
501 if ( isset( $user->ID ) ) {
502 $shortcode['[yaymail_user_id]'] = $user->ID;
503 }
504 }
505 }
506 if ( ! empty( $args ) ) {
507 $postID = CustomPostType::postIDByTemplate( $this->template );
508 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
509 $yaymail_settings = get_option( 'yaymail_settings' );
510 $yaymail_informations = Helper::inforShortcode( $postID, $this->template, array() );
511
512 if ( isset( $args['email'] ) || isset( $args['admin_email'] ) || isset( $args['user'] ) ) {
513 if ( isset( $args['email']->id ) && 'customer_reset_password' == $args['email']->id ) {
514 $user = new \WP_User( intval( $args['email']->user_id ) );
515 $shortcode['[yaymail_customer_username]'] = $args['email']->user_login;
516 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
517 $shortcode['[yaymail_customer_first_name]'] = get_user_meta( $user->ID, 'first_name', true );
518 $shortcode['[yaymail_customer_last_name]'] = get_user_meta( $user->ID, 'last_name', true );
519 $shortcode['[yaymail_user_email]'] = $args['email']->user_email;
520 $shortcode['[yaymail_user_id]'] = $user->ID;
521 if ( isset( $args['reset_key'] ) ) {
522 $link_reset = add_query_arg(
523 array(
524 'key' => $args['reset_key'],
525 'id' => $user->ID,
526 ),
527 wc_get_endpoint_url( 'lost-password', '', wc_get_page_permalink( 'myaccount' ) )
528 );
529 $shortcode['[yaymail_password_reset_url]'] = '<a style="color: ' . esc_attr( $text_link_color ) . ';" href="' . esc_url( $link_reset ) . '">' . esc_html__( 'Click here to reset your password', 'woocommerce' ) . '</a>';
530 $shortcode['[yaymail_password_reset_url_string]'] = esc_url( $link_reset );
531 }
532
533 // link reset password send by wp
534 if ( isset( $args['email']->user_login ) && isset( $args['email']->user_data ) && isset( $args['email']->key ) ) {
535 $locale = get_user_locale( $args['email']->user_data );
536 $key = $args['email']->key;
537 $user_login = $args['email']->user_login;
538 $shortcode['[yaymail_wp_password_reset_url]'] = network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . '&wp_lang=' . $locale;
539 }
540
541 $shortcode['[yaymail_site_name]'] = esc_html( get_bloginfo( 'name' ) );
542 }
543
544 $shortcode['[yaymail_site_name]'] = esc_html( get_bloginfo( 'name' ) );
545 $shortcode['[yaymail_site_url]'] = '<a style="color: ' . esc_attr( $text_link_color ) . ';" href="' . esc_url( get_home_url() ) . '"> ' . esc_url( get_home_url() ) . ' </a>';
546 $shortcode['[yaymail_site_url_string]'] = esc_url( get_home_url() );
547 $shortcode['[yaymail_user_account_url]'] = '<a style="color:' . esc_attr( $text_link_color ) . '; font-weight: normal; text-decoration: underline;" href="' . wc_get_page_permalink( 'myaccount' ) . '">' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '</a>';
548 $shortcode['[yaymail_user_account_url_string]'] = wc_get_page_permalink( 'myaccount' );
549 if ( isset( $args['email']->user_pass ) && ! empty( $args['email']->user_pass ) ) {
550 $shortcode['[yaymail_user_new_password]'] = $args['email']->user_pass;
551 } else {
552 if ( isset( $_REQUEST['pass1-text'] ) && '' != $_REQUEST['pass1-text'] ) {
553 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
554 } elseif ( isset( $_REQUEST['pass1'] ) && '' != $_REQUEST['pass1'] ) {
555 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
556 } else {
557 $shortcode['[yaymail_user_new_password]'] = '';
558 }
559 }
560
561 if ( isset( $args['set_password_url'] ) && ! empty( $args['set_password_url'] ) ) {
562 $shortcode['[yaymail_set_password_url_string]'] = $args['set_password_url'];
563 }
564
565 if ( isset( $args['email']->user_login ) && ! empty( $args['email']->user_login ) ) {
566 $shortcode['[yaymail_customer_username]'] = $args['email']->user_login;
567 $user = get_user_by( 'email', $args['email']->user_email );
568 if ( ! empty( get_user_meta( $user->ID, 'first_name', true ) ) && ! empty( get_user_meta( $user->ID, 'last_name', true ) ) ) {
569 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
570 $shortcode['[yaymail_customer_first_name]'] = get_user_meta( $user->ID, 'first_name', true );
571 $shortcode['[yaymail_customer_last_name]'] = get_user_meta( $user->ID, 'last_name', true );
572 } elseif ( isset( $_REQUEST['first_name'] ) && isset( $_REQUEST['last_name'] ) ) {
573 $shortcode['[yaymail_customer_name]'] = sanitize_text_field( $_REQUEST['first_name'] ) . ' ' . sanitize_text_field( $_REQUEST['last_name'] );
574 $shortcode['[yaymail_customer_first_name]'] = sanitize_text_field( $_REQUEST['first_name'] );
575 $shortcode['[yaymail_customer_last_name]'] = sanitize_text_field( $_REQUEST['last_name'] );
576 }
577 }
578 if ( isset( $args['email']->user_email ) && ! empty( $args['email']->user_email ) ) {
579 $shortcode['[yaymail_user_email]'] = $args['email']->user_email;
580 }
581 if ( isset( $args['email']->id ) && ( 'customer_new_account_activation' == $args['email']->id ) ) { // customer_new_account_activation : Template of Germanized plugin, New Account template use shortcode [yaymail_set_password_url_string] is activation link
582 if ( 'customer_new_account_activation' == $args['email']->id ) {
583 if ( isset( $args['email']->user_activation_url ) && ! empty( $args['email']->user_activation_url ) ) {
584 $shortcode['[yaymail_user_activation_link]'] = $args['email']->user_activation_url;
585 }
586 } else {
587 if ( isset( $args['email']->user_login ) && ! empty( $args['email']->user_login ) ) {
588 global $wpdb, $wp_hasher;
589 $newHash = $wp_hasher;
590 // Generate something random for a password reset key.
591 $key = wp_generate_password( 20, false );
592
593 /**
594 *
595 * This action is documented in wp-login.php
596 */
597 do_action( 'retrieve_password_key', $args['email']->user_login, $key );
598
599 // Now insert the key, hashed, into the DB.
600 if ( empty( $wp_hasher ) ) {
601 if ( ! class_exists( 'PasswordHash' ) ) {
602 include_once ABSPATH . 'wp-includes/class-phpass.php';
603 }
604 $newHash = new \PasswordHash( 8, true );
605 }
606 $hashed = time() . ':' . $newHash->HashPassword( $key );
607 $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $args['email']->user_login ) );
608 $activation_url = network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $args['email']->user_login ), 'login' );
609 $shortcode['[yaymail_user_activation_link]'] = $activation_url;
610 }
611 }
612 }
613
614 // Define shortcode from plugin addon
615 $shortcode = apply_filters( 'yaymail_do_shortcode', $shortcode, $yaymail_informations, $args );
616 // Define customs shortcode for user
617 $shortcode = apply_filters( 'yaymail_customs_shortcode', $shortcode, $yaymail_informations, $args );
618
619 } else {
620 // Define shortcode from plugin addon not have args[''email]
621 $shortcode = apply_filters( 'yaymail_do_shortcode', $shortcode, $yaymail_informations, $args );
622 // Define customs shortcode for user
623 $shortcode = apply_filters( 'yaymail_customs_shortcode', $shortcode, $yaymail_informations, $args );
624
625 }
626 }
627
628 // support plugin YITH WooCommerce Coupon Email System Premium
629 if ( class_exists( 'YITH_WC_Coupon_Email_System' ) ) {
630 $shortcode['[yaymail_site_name]'] = esc_html( get_bloginfo( 'name' ) );
631 }
632
633 $this->order_data = $shortcode;
634 }
635 }
636 public function shortcodeCallBack( $atts, $content, $tag ) {
637
638 return isset( $this->order_data[ '[' . $tag . ']' ] ) ? $this->order_data[ '[' . $tag . ']' ] : false;
639
640 }
641
642 public function templateParser() {
643 // Helper::checkNonce();
644 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : '';
645 if ( ! wp_verify_nonce( $nonce, 'email-nonce' ) ) {
646 wp_send_json_error( array( 'mess' => 'Nonce is invalid' ) );
647 } else {
648 $request = $_POST;
649 $this->order_id = false;
650 if ( isset( $request['order_id'] ) ) {
651 $order_id = sanitize_text_field( $request['order_id'] );
652 if ( 'sampleOrder' !== $order_id ) {
653 $order_id = intval( $order_id );
654 }
655 if ( ! $order_id ) {
656 $order_id = '';
657 }
658
659 $this->template = isset( $request['template'] ) ? sanitize_text_field( $request['template'] ) : false;
660 $this->order_id = $order_id;
661 }
662
663 if ( ! $this->order_id || ! $this->template ) {
664 return false;
665 }
666
667 if ( 'sampleOrder' !== $order_id ) {
668 $this->order = new \WC_Order( $this->order_id );
669 }
670
671 if ( 'sampleOrder' !== $order_id && ( is_null( $this->order ) || empty( $this->order ) || ! isset( $this->order ) ) ) {
672 return false;
673 }
674
675 if ( 'sampleOrder' !== $order_id ) {
676 $this->collectOrderData();
677 $this->collectOrderDataHasFunction();
678 } else {
679 $this->defaultSampleOrderData();
680 }
681
682 $result = (object) array();
683 $result->order_id = $this->order_id;
684 $result->order_data = $this->order_data;
685
686 $shortcode_order_meta = array();
687 $shortcode_order_custom_meta = array();
688 $shortcode_order_taxes = array();
689 if ( 'sampleOrder' !== $order_id ) {
690 $result->order = $this->order;
691 $result->order_items = $result->order->get_items();
692 $result->user_details = $result->order->get_user();
693
694 /*
695 @@@@ Get name field in custom field of order woocommerce.
696 */
697 $order_metaArr = get_post_meta( $order_id );
698 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
699 $pattern = '/^_.*/i';
700 $n = 0;
701 foreach ( $order_metaArr as $k => $v ) {
702 // @@@ starts with the "_" character of the woo field.
703 if ( ! preg_match( $pattern, $k ) ) {
704 $nameField = str_replace( ' ', '_', trim( $k ) );
705 $nameShorcode = '[yaymail_post_meta:' . $nameField . ']';
706 $key_order_meta = 'post_meta:' . $nameField . '_' . $n;
707 $shortcode_order_meta[] = array(
708 'key' => $key_order_meta,
709 $nameShorcode => 'Loads value of order meta key - ' . $nameField,
710 );
711 $n++;
712 }
713 }
714 }
715 if ( ! empty( $result->order ) ) {
716 foreach ( $result->order->get_meta_data() as $meta ) {
717 $nameField = str_replace( ' ', '_', trim( $meta->get_data()['key'] ) );
718 $nameShorcode = '[yaymail_order_meta:' . $nameField . ']';
719 $key_order_custom_meta = 'order_meta:' . $nameField;
720 $shortcode_order_custom_meta[] = array(
721 'key' => $key_order_custom_meta,
722 $nameShorcode => 'Loads value of order custom meta key - ' . $nameField,
723 );
724 }
725 foreach ( $result->order->get_items( 'tax' ) as $item_id => $item_tax ) {
726 $tax_rate_id = $item_tax->get_rate_id();
727 $shortcode_order_taxes[] = array(
728 'key' => '[yaymail_order_taxes_' . $tax_rate_id . ']',
729 'name' => $item_tax->get_label(),
730 );
731 }
732 }
733 } else {
734 $result->order = '';
735 $result->order_items = '';
736 $result->user_details = '';
737 }
738 $real_postID = '';
739 if ( isset( $request['template'] ) ) {
740 if ( CustomPostType::postIDByTemplate( $this->template ) ) {
741 $postID = CustomPostType::postIDByTemplate( $this->template );
742 $real_postID = $postID;
743 $emailTemplate = get_post( $postID );
744 $updateElement = new UpdateElement();
745 $yaymail_elements = get_post_meta( $postID, '_yaymail_elements', true );
746 $list_elements = Helper::preventXSS( $yaymail_elements );
747
748 $yaymailSettingsDefaultLogo = get_option( 'yaymail_settings_default_logo' );
749 $set_default_logo = false != $yaymailSettingsDefaultLogo ? $yaymailSettingsDefaultLogo['set_default'] : '0';
750 $yaymailSettingsDefaultFooter = get_option( 'yaymail_settings_default_footer' );
751 $set_default_footer = false != $yaymailSettingsDefaultFooter ? $yaymailSettingsDefaultFooter['set_default'] : '0';
752 $reviewYayMail = get_option( 'yaymail_review' );
753
754 $make_args['order'] = $this->order;
755 $array_element = array();
756 foreach ( $list_elements as $key => $element ) {
757 if ( has_filter( 'yaymail_addon_for_conditional_logic' ) && ! empty( $make_args['order'] ) && isset( $element['settingRow']['arrConditionLogic'] ) && ! empty( $element['settingRow']['arrConditionLogic'] ) ) {
758 $conditional_Logic = apply_filters( 'yaymail_addon_for_conditional_logic', false, $make_args, $element['settingRow'] );
759
760 if ( $conditional_Logic ) {
761 $array_element[] = $element;
762 }
763 } else {
764 $array_element[] = $element;
765 }
766 }
767
768 // Check and update order items tilte
769 if ( ! metadata_exists( 'post', $postID, '_yaymail_email_order_item_title' ) || empty( get_post_meta( $postID, '_yaymail_email_order_item_title', true ) ) ) {
770 $orderItemsTitle = Helper::OrderItemsTitle();
771 update_post_meta( $postID, '_yaymail_email_order_item_title', $orderItemsTitle );
772 } else {
773 $orderItemsTitle = Helper::OrderItemsTitle();
774 $yaymail_email_order_item_title = get_post_meta( $postID, '_yaymail_email_order_item_title', true );
775 $merge_yaymail_email_order_item_title = array_merge( $orderItemsTitle, $yaymail_email_order_item_title );
776 update_post_meta( $postID, '_yaymail_email_order_item_title', $merge_yaymail_email_order_item_title );
777 }
778 if ( ! metadata_exists( 'post', $postID, '_yaymail_email_order_item_download_title' ) || empty( get_post_meta( $postID, '_yaymail_email_order_item_download_title', true ) ) ) {
779 $orderItemsDownloadsTitle = Helper::OrderItemsDownloadsTitle();
780 update_post_meta( $postID, '_yaymail_email_order_item_download_title', $orderItemsDownloadsTitle );
781 }
782
783 $result->elements = Helper::unsanitize_array( $updateElement->merge_new_props_to_elements( $array_element ) );
784 $result->emailBackgroundColor = get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : 'rgb(236, 236, 236)';
785 $result->emailTextLinkColor = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
786 $result->titleShipping = get_post_meta( $postID, '_email_title_shipping', true ) ? get_post_meta( $postID, '_email_title_shipping', true ) : 'Shipping Address';
787 $result->titleBilling = get_post_meta( $postID, '_email_title_billing', true ) ? get_post_meta( $postID, '_email_title_billing', true ) : 'Billing Address';
788 $result->orderTitle = get_post_meta( $postID, '_yaymail_email_order_item_title', true );
789 $result->orderItemsDownloadTitle = get_post_meta( $postID, '_yaymail_email_order_item_download_title', true ) ? get_post_meta( $postID, '_yaymail_email_order_item_download_title', true ) : Helper::OrderItemsDownloadsTitle();
790 $result->customCSS = $this->applyCSSFormat();
791 $result->shortcode_order_meta = $shortcode_order_meta;
792 $result->shortcode_order_custom_meta = $shortcode_order_custom_meta;
793 $result->shortcode_order_taxes = $shortcode_order_taxes;
794 $result->set_default_logo = $set_default_logo;
795 $result->set_default_footer = $set_default_footer;
796 $result->review_yaymail = $reviewYayMail;
797
798 }
799 }
800 $result->yaymailAddonTemps = Helper::replaceCustomAllowedHTMLTags( apply_filters( 'yaymail_addon_templates', array(), $result->order, $real_postID ) );
801
802 echo json_encode( $result );
803 die();
804 }
805 }
806 public function collectOrderDataHasFunction( $sent_to_admin = '', $args = array() ) {
807 $order = $this->order;
808 if ( empty( $this->order_id ) || empty( $order ) ) {
809 return false;
810 }
811 // Link Downloadable Product
812 $shortcode['[yaymail_items_downloadable_title]'] = $this->itemsDownloadableTitle( '', $this->order, $sent_to_admin, '' ); // done
813 $shortcode['[yaymail_items_downloadable_product]'] = $this->itemsDownloadableProduct( '', $this->order, $sent_to_admin, '' ); // done
814
815 // ORDER DETAILS
816 $shortcode['[yaymail_items_border]'] = $this->itemsBorder( '', $this->order, $sent_to_admin ); // done
817 $shortcode['[yaymail_items_border_before]'] = $this->itemsBorderBefore( '', $this->order, $sent_to_admin ); // done
818 $shortcode['[yaymail_items_border_after]'] = $this->itemsBorderAfter( '', $this->order, $sent_to_admin ); // done
819 $shortcode['[yaymail_items_border_title]'] = $this->itemsBorderTitle( '', $this->order, $sent_to_admin ); // done
820 $shortcode['[yaymail_items_border_content]'] = $this->itemsBorderContent( '', $this->order, $sent_to_admin ); // done
821 $shortcode['[yaymail_get_heading]'] = $this->getHeading( $args, $this->order, $sent_to_admin );
822
823 // WC HOOK
824 $shortcode['[woocommerce_email_order_meta]'] = $this->woocommerceEmailOrderMeta( $args, $sent_to_admin ); // not Changed
825 $shortcode['[woocommerce_email_order_details]'] = $this->woocommerceEmailOrderDetails( $args, $sent_to_admin ); // not Changed
826 $shortcode['[woocommerce_email_before_order_table]'] = $this->woocommerceEmailBeforeOrderTable( $args, $sent_to_admin ); // not Changed
827 $shortcode['[woocommerce_email_after_order_table]'] = $this->woocommerceEmailAfterOrderTable( $args, $sent_to_admin ); // not Changed
828
829 $shortcode['[yaymail_billing_shipping_address]'] = $this->billingShippingAddress( '', $this->order ); // done
830
831 $shortcode['[yaymail_billing_shipping_address_title]'] = $this->billingShippingAddressTitle( '', $this->order ); // done
832 $shortcode['[yaymail_billing_shipping_address_content]'] = $this->billingShippingAddressContent( '', $this->order ); // done
833 $shortcode['[yaymail_check_billing_shipping_address]'] = $this->checkBillingShippingAddress( '', $this->order );
834 $shortcode['[yaymail_order_coupon_codes]'] = $this->orderCouponCodes( '', $this->order );
835
836 //Support shortcode for WooCommerce for LatePoint
837 if ( class_exists( 'TechXelaLatePointPaymentsWooCommerce' ) ) {
838 $shortcode['[yaymail_woo_latepoint_booking_detail]'] = WooLatepoint::wooLatepointBookingDetail( $args, $this->order, $sent_to_admin );
839
840 $shortcode['[yaymail_woo_latepoint_caption]'] = WooLatepoint::wooLatepointCaption( $args, $this->order, $sent_to_admin );
841 $shortcode['[yaymail_woo_latepoint_bg_color]'] = WooLatepoint::wooLatepointBgColor( $args, $this->order, $sent_to_admin );
842 $shortcode['[yaymail_woo_latepoint_text_color]'] = WooLatepoint::wooLatepointTextColor( $args, $this->order, $sent_to_admin );
843 $shortcode['[yaymail_woo_latepoint_font_size]'] = WooLatepoint::wooLatepointFontSize( $args, $this->order, $sent_to_admin );
844 $shortcode['[yaymail_woo_latepoint_border]'] = WooLatepoint::wooLatepointBorder( $args, $this->order, $sent_to_admin );
845 $shortcode['[yaymail_woo_latepoint_border_radius]'] = WooLatepoint::wooLatepointBorderRadius( $args, $this->order, $sent_to_admin );
846 $shortcode['[yaymail_woo_latepoint_margin]'] = WooLatepoint::wooLatepointMargin( $args, $this->order, $sent_to_admin );
847 $shortcode['[yaymail_woo_latepoint_padding]'] = WooLatepoint::wooLatepointPaddings( $args, $this->order, $sent_to_admin );
848 $shortcode['[yaymail_woo_latepoint_css]'] = WooLatepoint::wooLatepointCss( $args, $this->order, $sent_to_admin );
849 $shortcode['[yaymail_woo_latepoint_show_locations]'] = WooLatepoint::wooLatepointShowLocations( $args, $this->order, $sent_to_admin );
850 $shortcode['[yaymail_woo_latepoint_show_agents]'] = WooLatepoint::wooLatepointShowAgents( $args, $this->order, $sent_to_admin );
851 $shortcode['[yaymail_woo_latepoint_show_services]'] = WooLatepoint::wooLatepointShowServices( $args, $this->order, $sent_to_admin );
852 $shortcode['[yaymail_woo_latepoint_show_service_categories]'] = WooLatepoint::wooLatepointShowServiceCategories( $args, $this->order, $sent_to_admin );
853
854 $shortcode['[yaymail_woo_latepoint_selected_location]'] = WooLatepoint::wooLatepointSelectedLocation( $args, $this->order, $sent_to_admin );
855 $shortcode['[yaymail_woo_latepoint_selected_agent]'] = WooLatepoint::wooLatepointSelectedAgent( $args, $this->order, $sent_to_admin );
856 $shortcode['[yaymail_woo_latepoint_selected_service]'] = WooLatepoint::wooLatepointSelectedService( $args, $this->order, $sent_to_admin );
857 $shortcode['[yaymail_woo_latepoint_selected_service_category]'] = WooLatepoint::wooLatepointSelectedServiceCategory( $args, $this->order, $sent_to_admin );
858 $shortcode['[yaymail_woo_latepoint_selected_duration]'] = WooLatepoint::wooLatepointSelectedDuration( $args, $this->order, $sent_to_admin );
859 $shortcode['[yaymail_woo_latepoint_selected_total_attendees]'] = WooLatepoint::wooLatepointSelectedTotalAttendees( $args, $this->order, $sent_to_admin );
860
861 $shortcode['[yaymail_woo_latepoint_calendar_start_date]'] = WooLatepoint::wooLatepointCalendarStartDate( $args, $this->order, $sent_to_admin );
862 $shortcode['[yaymail_woo_latepoint_hide_side_panel]'] = WooLatepoint::wooLatepointHideSidePanel( $args, $this->order, $sent_to_admin );
863 $shortcode['[yaymail_woo_latepoint_hide_summary]'] = WooLatepoint::wooLatepointHideSummary( $args, $this->order, $sent_to_admin );
864 }
865
866 $this->order_data = array_merge( $this->order_data, $shortcode );
867 }
868
869 public function collectOrderData( $sent_to_admin = '', $args = array() ) {
870 $shortcode = array();
871 $order = $this->order;
872 if ( empty( $this->order_id ) || empty( $order ) ) {
873 return false;
874 }
875
876 // Getting Fee & Refunds:
877 $fee = 0;
878 $refund = 0;
879 $totals = $order->get_order_item_totals();
880 foreach ( $totals as $index => $value ) {
881 if ( strpos( $index, 'fee' ) !== false ) {
882 $fees = $order->get_fees();
883 foreach ( $fees as $feeVal ) {
884 if ( method_exists( $feeVal, 'get_amount' ) ) {
885 $fee += (float) $feeVal->get_amount();
886 }
887 }
888 }
889 if ( strpos( $index, 'refund' ) !== false ) {
890 $refund = $order->get_total_refunded();
891 }
892 }
893 // User Info
894 $user_data = $order->get_user();
895 $created_date = $order->get_date_created();
896 $items = $order->get_items();
897 $yaymail_settings = get_option( 'yaymail_settings' );
898 $order_url = $order->get_edit_order_url();
899 // if ( class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ) {
900 // add_action(
901 // 'woocommerce_email_customer_details',
902 // function( $order ) {
903 // if ( 'Shortcodes.php' === basename( __FILE__ ) ) {
904 // $this->shipping_address = $order->get_formatted_shipping_address();
905 // $this->billing_address = $order->get_formatted_billing_address();
906 // }
907 // },
908 // 100,
909 // 1
910 // );
911 // ob_start();
912 // do_action( 'woocommerce_email_customer_details', $order );
913 // $delete_write = ob_get_contents();
914 // ob_end_clean();
915 // }
916 $this->shipping_address = $order->get_formatted_shipping_address();
917 $this->billing_address = $order->get_formatted_billing_address();
918 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
919 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
920 $postID = CustomPostType::postIDByTemplate( $this->template );
921 $yaymail_informations = Helper::inforShortcode( $postID, $this->template, $order );
922
923 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
924 if ( $order->get_billing_phone() ) {
925 $billing_address .= "<br/> <a href='tel:" . esc_html( $order->get_billing_phone() ) . "' style='color:" . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_phone() ) . '</a>';
926 }
927 if ( $order->get_billing_email() ) {
928 $billing_address .= "<br/><a href='mailto:" . esc_html( $order->get_billing_email() ) . "' style='color:" . esc_attr( $text_link_color ) . ";font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_email() ) . '</a>';
929 }
930 $customerNotes = $order->get_customer_order_notes();
931 $customerNoteHtmlList = '';
932 $customerNoteHtml = $customerNoteHtmlList;
933 if ( ! empty( $customerNotes ) && count( $customerNotes ) ) {
934 $customerNoteHtmlList = $this->getOrderCustomerNotes( $customerNotes );
935 $customerNote_single[] = $customerNotes[0];
936 $customerNoteHtml = $this->getOrderCustomerNotes( $customerNote_single );
937 }
938
939 $resetURL = '';
940 if ( isset( $args['email']->reset_key ) && ! empty( $args['email']->reset_key )
941 && isset( $args['email']->user_login ) && ! empty( $args['email']->user_login )
942 ) {
943 $user = new \WP_User( intval( $args['email']->user_id ) );
944 $reset_key = get_password_reset_key( $user );
945 $resetURL = esc_url(
946 add_query_arg(
947 array(
948 'key' => $reset_key,
949 'login' => rawurlencode( $args['email']->user_login ),
950 ),
951 wc_get_endpoint_url( 'lost-password', '', wc_get_page_permalink( 'myaccount' ) )
952 )
953 );
954 }
955
956 if ( null != $created_date ) {
957 $shortcode['[yaymail_order_date]'] = $order->get_date_created()->date_i18n( wc_date_format() );
958 } else {
959 $shortcode['[yaymail_order_date]'] = '';
960 }
961 $shortcode['[yaymail_order_fee]'] = $fee;
962 if ( ! empty( $order->get_id() ) ) {
963 $shortcode['[yaymail_order_id]'] = $order->get_id();
964 } else {
965 $shortcode['[yaymail_order_id]'] = '';
966 }
967 $shortcode['[yaymail_order_link]'] = '<a href="' . esc_url( $order_url ) . '" style="color:' . esc_attr( $text_link_color ) . ';">' . esc_html__( 'Order', 'yaymail' ) . '</a>';
968 $shortcode['[yaymail_order_link]'] = str_replace( '[yaymail_order_id]', $order->get_id(), $shortcode['[yaymail_order_link]'] );
969 $shortcode['[yaymail_order_link_string]'] = esc_url( $order_url );
970 if ( ! empty( $order->get_order_number() ) ) {
971 $shortcode['[yaymail_order_number]'] = $order->get_order_number();
972 } else {
973 $shortcode['[yaymail_order_number]'] = '';
974 }
975 $shortcode['[yaymail_order_refund]'] = $refund;
976 if ( isset( $totals['cart_subtotal']['value'] ) ) {
977 $shortcode['[yaymail_order_sub_total]'] = $totals['cart_subtotal']['value'];
978 } else {
979 $shortcode['[yaymail_order_sub_total]'] = '';
980 }
981
982 if ( isset( $totals['discount']['value'] ) ) {
983 $shortcode['[yaymail_order_discount]'] = $totals['discount']['value'];
984 }
985
986 $shortcode['[yaymail_order_total]'] = wc_price( $order->get_total() );
987 $shortcode['[yaymail_order_total_numbers]'] = $order->get_total();
988 $shortcode['[yaymail_orders_count]'] = count( $order->get_items() );
989 $shortcode['[yaymail_quantity_count]'] = $order->get_item_count();
990 $shortcode['[yaymail_orders_count_double]'] = count( $order->get_items() ) * 2;
991
992 // PAYMENTS
993 if ( isset( $totals['payment_method']['value'] ) ) {
994 $shortcode['[yaymail_order_payment_method]'] = $totals['payment_method']['value'];
995 } else {
996 $shortcode['[yaymail_order_payment_method]'] = '';
997 }
998 $shortcode['[yaymail_order_payment_url]'] = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Payment page', 'yaymail' ) . '</a>';
999 $shortcode['[yaymail_order_payment_url_string]'] = esc_url( $order->get_checkout_payment_url() );
1000 $shortcode['[yaymail_payment_instruction]'] = $this->orderPaymentInstructions( $this->order, $sent_to_admin );
1001 foreach ( $order->get_items( 'tax' ) as $item_id => $item_tax ) {
1002 $tax_rate_id = $item_tax->get_rate_id();
1003
1004 $shortcode_order_taxes = '[yaymail_order_taxes_' . $tax_rate_id . ']';
1005 $tax_amount_total = $item_tax->get_tax_total(); // Tax rate total
1006 $tax_shipping_total = $item_tax->get_shipping_tax_total(); // Tax shipping total
1007 $totals_taxes = $tax_amount_total + $tax_shipping_total;
1008
1009 $shortcode[ $shortcode_order_taxes ] = wc_price( $totals_taxes );
1010 }
1011 if ( ! empty( $order->get_payment_method_title() ) ) {
1012 $shortcode['[yaymail_payment_method]'] = $order->get_payment_method_title();
1013 } else {
1014 $shortcode['[yaymail_payment_method]'] = '';
1015 }
1016 if ( ! empty( $order->get_transaction_id() ) ) {
1017 $shortcode['[yaymail_transaction_id]'] = $order->get_transaction_id();
1018 } else {
1019 $shortcode['[yaymail_transaction_id]'] = '';
1020 }
1021
1022 // SHIPPINGS
1023 if ( ! empty( $order->calculate_shipping() ) ) {
1024 $shortcode['[yaymail_order_shipping]'] = $order->calculate_shipping();
1025 } else {
1026 $shortcode['[yaymail_order_shipping]'] = 0;
1027 }
1028 $shortcode['[yaymail_shipping_address]'] = $shipping_address;
1029 if ( ! empty( $order->get_shipping_address_1() ) ) {
1030 $shortcode['[yaymail_shipping_address_1]'] = $order->get_shipping_address_1();
1031 } else {
1032 $shortcode['[yaymail_shipping_address_1]'] = '';
1033 }
1034 if ( ! empty( $order->get_shipping_address_2() ) ) {
1035 $shortcode['[yaymail_shipping_address_2]'] = $order->get_shipping_address_2();
1036 } else {
1037 $shortcode['[yaymail_shipping_address_2]'] = '';
1038 }
1039 if ( ! empty( $order->get_shipping_city() ) ) {
1040 $shortcode['[yaymail_shipping_city]'] = $order->get_shipping_city();
1041 } else {
1042 $shortcode['[yaymail_shipping_city]'] = '';
1043 }
1044 if ( ! empty( $order->get_shipping_company() ) ) {
1045 $shortcode['[yaymail_shipping_company]'] = $order->get_shipping_company();
1046 } else {
1047 $shortcode['[yaymail_shipping_company]'] = '';
1048 }
1049 if ( ! empty( $order->get_shipping_country() ) ) {
1050 $country_code_bym = $order->get_shipping_country();
1051 $wc_countries = WC()->countries;
1052 $shipping_country_name_bym = $wc_countries->countries[ $country_code_bym ];
1053 $shortcode['[yaymail_shipping_country]'] = $shipping_country_name_bym;
1054 } else {
1055 $shortcode['[yaymail_shipping_country]'] = '';
1056 }
1057 if ( ! empty( $order->get_shipping_first_name() ) ) {
1058 $shortcode['[yaymail_shipping_first_name]'] = $order->get_shipping_first_name();
1059 } else {
1060 $shortcode['[yaymail_shipping_first_name]'] = '';
1061
1062 }
1063 if ( ! empty( $order->get_shipping_last_name() ) ) {
1064 $shortcode['[yaymail_shipping_last_name]'] = $order->get_shipping_last_name();
1065 } else {
1066 $shortcode['[yaymail_shipping_last_name]'] = '';
1067
1068 }
1069 if ( ! empty( $order->get_shipping_method() ) ) {
1070 $shortcode['[yaymail_shipping_method]'] = $order->get_shipping_method();
1071 } else {
1072 $shortcode['[yaymail_shipping_method]'] = '';
1073 }
1074 if ( ! empty( $order->get_shipping_postcode() ) ) {
1075 $shortcode['[yaymail_shipping_postcode]'] = $order->get_shipping_postcode();
1076 } else {
1077 $shortcode['[yaymail_shipping_postcode]'] = '';
1078 }
1079 if ( ! empty( $order->get_shipping_state() ) ) {
1080 $shortcode['[yaymail_shipping_state]'] = $order->get_shipping_state();
1081 } else {
1082 $shortcode['[yaymail_shipping_state]'] = '';
1083 }
1084 if ( method_exists( $order, 'get_shipping_phone' ) && ! empty( $order->get_shipping_phone() ) ) {
1085 $shortcode['[yaymail_shipping_phone]'] = $order->get_shipping_phone();
1086 } else {
1087 $shortcode['[yaymail_shipping_phone]'] = '';
1088 }
1089
1090 // BILLINGS
1091 $shortcode['[yaymail_billing_address]'] = $billing_address;
1092 if ( ! empty( $order->get_billing_address_1() ) ) {
1093 $shortcode['[yaymail_billing_address_1]'] = $order->get_billing_address_1();
1094 } else {
1095 $shortcode['[yaymail_billing_address_1]'] = '';
1096 }
1097 if ( ! empty( $order->get_billing_address_2() ) ) {
1098 $shortcode['[yaymail_billing_address_2]'] = $order->get_billing_address_2();
1099 } else {
1100 $shortcode['[yaymail_billing_address_2]'] = '';
1101 }
1102 if ( ! empty( $order->get_billing_city() ) ) {
1103 $shortcode['[yaymail_billing_city]'] = $order->get_billing_city();
1104 } else {
1105 $shortcode['[yaymail_billing_city]'] = $order->get_billing_city();
1106 }
1107 if ( ! empty( $order->get_billing_company() ) ) {
1108 $shortcode['[yaymail_billing_company]'] = $order->get_billing_company();
1109 } else {
1110 $shortcode['[yaymail_billing_company]'] = '';
1111 }
1112 if ( ! empty( $order->get_billing_country() ) ) {
1113 $country_code_bym = $order->get_billing_country();
1114 $wc_countries = WC()->countries;
1115 $billing_country_name_bym = $wc_countries->countries[ $country_code_bym ];
1116 $shortcode['[yaymail_billing_country]'] = $billing_country_name_bym;
1117 } else {
1118 $shortcode['[yaymail_billing_country]'] = '';
1119 }
1120 if ( ! empty( $order->get_billing_email() ) ) {
1121 $shortcode['[yaymail_billing_email]'] = '<a style="color: inherit" href="mailto:' . $order->get_billing_email() . '">' . $order->get_billing_email() . '</a>';
1122 } else {
1123 $shortcode['[yaymail_billing_email]'] = '';
1124 }
1125 if ( ! empty( $order->get_billing_first_name() ) ) {
1126 $shortcode['[yaymail_billing_first_name]'] = $order->get_billing_first_name();
1127 } else {
1128 $shortcode['[yaymail_billing_first_name]'] = '';
1129 }
1130 if ( ! empty( $order->get_billing_last_name() ) ) {
1131 $shortcode['[yaymail_billing_last_name]'] = $order->get_billing_last_name();
1132 } else {
1133 $shortcode['[yaymail_billing_last_name]'] = '';
1134 }
1135 if ( ! empty( $order->get_billing_phone() ) ) {
1136 $shortcode['[yaymail_billing_phone]'] = $order->get_billing_phone();
1137 } else {
1138 $shortcode['[yaymail_billing_phone]'] = '';
1139 }
1140 if ( ! empty( $order->get_billing_postcode() ) ) {
1141 $shortcode['[yaymail_billing_postcode]'] = $order->get_billing_postcode();
1142 } else {
1143 $shortcode['[yaymail_billing_postcode]'] = '';
1144 }
1145 if ( ! empty( $order->get_billing_state() ) ) {
1146 $shortcode['[yaymail_billing_state]'] = $order->get_billing_state();
1147 } else {
1148 $shortcode['[yaymail_billing_state]'] = '';
1149 }
1150
1151 // Reset Passwords
1152 $shortcode['[yaymail_password_reset_url]'] = '<a style="color: ' . esc_attr( $text_link_color ) . ';" href="' . esc_url( $resetURL ) . '">' . esc_html__( 'Click here to reset your password', 'woocommerce' ) . '</a>';
1153 $shortcode['[yaymail_password_reset_url_string]'] = esc_url( $resetURL );
1154
1155 // New Users
1156 if ( isset( $args['email']->user_pass ) && ! empty( $args['email']->user_pass ) ) {
1157 $shortcode['[yaymail_user_new_password]'] = $args['email']->user_pass;
1158 } else {
1159 if ( isset( $_REQUEST['pass1-text'] ) && '' != $_REQUEST['pass1-text'] ) {
1160 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
1161 } elseif ( isset( $_REQUEST['pass1'] ) && '' != $_REQUEST['pass1'] ) {
1162 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
1163 } else {
1164 $shortcode['[yaymail_user_new_password]'] = '';
1165 }
1166 }
1167 // Review this code ??
1168 if ( isset( $args['email']->user_activation_url ) && ! empty( $args['email']->user_activation_url ) ) {
1169 $shortcode['[yaymail_user_activation_link]'] = $args['email']->user_activation_url;
1170 } else {
1171 $shortcode['[yaymail_user_activation_link]'] = '';
1172 }
1173
1174 // GENERALS
1175 $shortcode['[yaymail_customer_note]'] = ( $customerNoteHtml ); // add strip_tags() to remove link
1176 $shortcode['[yaymail_customer_notes]'] = $customerNoteHtmlList;
1177 if ( ! empty( $order->get_customer_note() ) ) {
1178 $shortcode['[yaymail_customer_provided_note]'] = $order->get_customer_note();
1179 } else {
1180 $shortcode['[yaymail_customer_provided_note]'] = '';
1181 }
1182 $shortcode['[yaymail_site_name]'] = esc_html( get_bloginfo( 'name' ) );
1183 $shortcode['[yaymail_site_url]'] = '<a style="color: ' . esc_attr( $text_link_color ) . ';" href="' . esc_url( get_home_url() ) . '"> ' . esc_url( get_home_url() ) . ' </a>';
1184 $shortcode['[yaymail_site_url_string]'] = esc_url( get_home_url() );
1185 if ( isset( $user_data->user_email ) ) {
1186 $shortcode['[yaymail_user_email]'] = $user_data->user_email;
1187 } else {
1188 $shortcode['[yaymail_user_email]'] = $order->get_billing_email();
1189 }
1190 if ( isset( $shortcode['[yaymail_user_email]'] ) && '' != $shortcode['[yaymail_user_email]'] ) {
1191 $user = get_user_by( 'email', $shortcode['[yaymail_user_email]'] );
1192 $shortcode['[yaymail_user_id]'] = ( isset( $user->ID ) ) ? $user->ID : '';
1193 }
1194 if ( isset( $user_data->user_login ) && ! empty( $user_data->user_login ) ) {
1195 $shortcode['[yaymail_customer_username]'] = $user_data->user_login;
1196 } elseif ( isset( $user_data->user_nicename ) ) {
1197 $shortcode['[yaymail_customer_username]'] = $user_data->user_nicename;
1198 } else {
1199 $shortcode['[yaymail_customer_username]'] = $order->get_billing_first_name();
1200 }
1201 if ( isset( $user_data->roles ) && ! empty( $user_data->roles ) ) {
1202 $shortcode['[yaymail_customer_roles]'] = implode( ', ', $user_data->roles );
1203 }
1204 if ( isset( $user->ID ) && ! empty( $user->ID ) ) {
1205 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
1206 $shortcode['[yaymail_customer_first_name]'] = get_user_meta( $user->ID, 'first_name', true );
1207 $shortcode['[yaymail_customer_last_name]'] = get_user_meta( $user->ID, 'last_name', true );
1208 } elseif ( isset( $user_data->user_nicename ) ) {
1209 $shortcode['[yaymail_customer_name]'] = $user_data->user_nicename;
1210 } else {
1211 $shortcode['[yaymail_customer_name]'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
1212 }
1213 if ( ! empty( $order->get_view_order_url() ) ) {
1214 $text_your_order = esc_html__( 'Your Order', 'yaymail' );
1215 $shortcode['[yaymail_view_order_url]'] = '<a href="' . esc_url( $order->get_view_order_url() ) . '" style="color:' . esc_attr( $text_link_color ) . ';">' . esc_html( $text_your_order ) . '</a>';
1216 $shortcode['[yaymail_view_order_url_string]'] = $order->get_view_order_url();
1217 } else {
1218 $shortcode['[yaymail_view_order_url]'] = '';
1219 }
1220
1221 if ( ! empty( parse_url( get_site_url() )['host'] ) ) {
1222 $shortcode['[yaymail_domain]'] = parse_url( get_site_url() )['host'];
1223 } else {
1224 $shortcode['[yaymail_domain]'] = '';
1225 }
1226
1227 $shortcode['[yaymail_user_account_url]'] = '<a style="color:' . esc_attr( $text_link_color ) . '; font-weight: normal; text-decoration: underline;" href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '">' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '</a>';
1228 $shortcode['[yaymail_user_account_url_string]'] = esc_url( wc_get_page_permalink( 'myaccount' ) );
1229
1230 // ADDITIONAL ORDER META:
1231 $order_metaArr = get_post_meta( $this->order_id );
1232 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
1233 foreach ( $order_metaArr as $k => $v ) {
1234 $nameField = str_replace( ' ', '_', trim( $k ) );
1235 $nameShorcode = '[yaymail_post_meta:' . $nameField . ']';
1236
1237 // when array $v has tow value ???
1238 if ( is_array( $v ) && count( $v ) > 0 ) {
1239 $shortcode[ $nameShorcode ] = trim( $v[0] );
1240 } else {
1241 $shortcode[ $nameShorcode ] = trim( $v );
1242 }
1243 }
1244 }
1245
1246 /*
1247 To get custom fields support Checkout Field Editor for WooCommerce */
1248 // funtion wc_get_custom_checkout_fields of Plugin Checkout Field Editor ????
1249 if ( ! empty( $order ) ) {
1250 if ( function_exists( 'wc_get_custom_checkout_fields' ) ) {
1251 $custom_fields = wc_get_custom_checkout_fields( $order );
1252 if ( ! empty( $custom_fields ) ) {
1253 foreach ( $custom_fields as $key => $custom_field ) {
1254 $shortcode[ '[yaymail_' . $key . ']' ] = get_post_meta( $order->get_id(), $key, true );
1255 }
1256 }
1257 }
1258 }
1259 if ( ! empty( $order ) ) {
1260 foreach ( $order->get_meta_data() as $meta ) {
1261 $nameField = str_replace( ' ', '_', trim( $meta->get_data()['key'] ) );
1262 $nameShorcode = '[yaymail_order_meta:' . $nameField . ']';
1263 if ( '_local_pickup_time_select' == $nameField ) {
1264 $plugin = \Local_Pickup_Time::get_instance();
1265 $shortcode[ $nameShorcode ] = $plugin->pickup_time_select_translatable( $meta->get_data()['value'] );
1266 } else {
1267 if ( is_array( $meta->get_data()['value'] ) ) {
1268 $checkNestedArray = false;
1269 foreach ( $meta->get_data()['value'] as $value ) {
1270 if ( is_object( $value ) || is_array( $value ) ) {
1271 $checkNestedArray = true;
1272 break;
1273 }
1274 }
1275 if ( false == $checkNestedArray ) {
1276 $shortcode[ $nameShorcode ] = implode( ', ', $meta->get_data()['value'] );
1277 } else {
1278 $shortcode[ $nameShorcode ] = '';
1279 if ( class_exists( 'WCPFC_Country' ) ) {
1280 $arr_values = \wcpfc_get_value_if_set( $meta->get_data(), array( 'value', 'value' ), '' );
1281 if ( is_object( $arr_values ) || is_array( $arr_values ) ) {
1282 $shortcode[ $nameShorcode ] = implode( ',', $arr_values );
1283 } else {
1284 $shortcode[ $nameShorcode ] = $arr_values;
1285 }
1286 }
1287 }
1288 } else {
1289 if ( is_string( $meta->get_data()['value'] ) ) {
1290 $value = $meta->get_data()['value'];
1291 $time = strtotime( $value );
1292 if ( $time ) {
1293 $date = \DateTime::createFromFormat( 'Y-m-d', $value );
1294 if ( $date ) {
1295 $shortcode[ $nameShorcode ] = date_i18n( wc_date_format(), $time );
1296 } else {
1297 $shortcode[ $nameShorcode ] = nl2br( $value );
1298 }
1299 } else {
1300 $shortcode[ $nameShorcode ] = nl2br( $value );
1301 }
1302 } else {
1303 $shortcode[ $nameShorcode ] = $meta->get_data()['value'];
1304 }
1305 }
1306 }
1307 }
1308 }
1309
1310 $shortcode['[yaymail_items]'] = $this->orderItems( $items, $sent_to_admin, '', true );
1311 $shortcode['[yaymail_items_products_quantity_price]'] = $this->orderItems( $items, $sent_to_admin, '', false );
1312
1313 // Define shortcode from plugin addon
1314 $shortcode = apply_filters( 'yaymail_do_shortcode', $shortcode, $yaymail_informations, $this->args_email );
1315 // Define customs shortcode for user
1316 $shortcode = apply_filters( 'yaymail_customs_shortcode', $shortcode, $yaymail_informations, $this->args_email );
1317
1318 $this->order_data = $shortcode;
1319 }
1320
1321 public function defaultSampleOrderData( $sent_to_admin = '' ) {
1322 $current_user = wp_get_current_user();
1323 $postID = CustomPostType::postIDByTemplate( $this->template );
1324 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
1325 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1326 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1327 $user_id = get_current_user_id();
1328 $yaymail_settings = get_option( 'yaymail_settings' );
1329 $yaymail_informations = Helper::inforShortcode( $postID, $this->template, array() );
1330
1331 // Link Downloadable Product
1332 $shortcode['[yaymail_items_downloadable_title]'] = $this->itemsDownloadableTitle( '', $this->order, $sent_to_admin, '' ); // done
1333 $shortcode['[yaymail_items_downloadable_product]'] = $this->itemsDownloadableProduct( '', $this->order, $sent_to_admin, '' ); // done
1334
1335 // ORDER DETAILS
1336 $shortcode['[yaymail_items_border]'] = $this->itemsBorder( '', $this->order, $sent_to_admin ); // done
1337
1338 $shortcode['[yaymail_items_border_before]'] = $this->itemsBorderBefore( '', $this->order, $sent_to_admin ); // done
1339 $shortcode['[yaymail_items_border_after]'] = $this->itemsBorderAfter( '', $this->order, $sent_to_admin ); // done
1340 $shortcode['[yaymail_items_border_title]'] = $this->itemsBorderTitle( '', $this->order, $sent_to_admin ); // done
1341 $shortcode['[yaymail_items_border_content]'] = $this->itemsBorderContent( '', $this->order, $sent_to_admin ); // done
1342 $shortcode['[yaymail_get_heading]'] = $this->getHeading( '', $this->order, $sent_to_admin );
1343
1344 // WC HOOK
1345 $shortcode['[woocommerce_email_order_meta]'] = $this->woocommerceEmailOrderMeta( array(), $sent_to_admin, 'sampleOrder' ); // not Changed
1346 $shortcode['[woocommerce_email_order_details]'] = $this->woocommerceEmailOrderDetails( array(), $sent_to_admin, 'sampleOrder' ); // not Changed
1347 $shortcode['[woocommerce_email_before_order_table]'] = $this->woocommerceEmailBeforeOrderTable( array(), $sent_to_admin, 'sampleOrder' ); // not changed
1348 $shortcode['[woocommerce_email_after_order_table]'] = $this->woocommerceEmailAfterOrderTable( array(), $sent_to_admin, 'sampleOrder' ); // not changed
1349
1350 // Define shortcode from plugin addon
1351 $shortcode = apply_filters( 'yaymail_do_shortcode', $shortcode, $yaymail_informations, '' );
1352 // Define customs shortcode for user
1353 $shortcode = apply_filters( 'yaymail_customs_shortcode', $shortcode, $yaymail_informations, '' );
1354
1355 $shortcode['[yaymail_items]'] = $this->orderItems( array(), $sent_to_admin, 'sampleOrder', true );
1356 $shortcode['[yaymail_items_products_quantity_price]'] = $this->orderItems( array(), $sent_to_admin, 'sampleOrder', false );
1357 $shortcode['[yaymail_order_date]'] = date_i18n( wc_date_format() );
1358 $shortcode['[yaymail_order_fee]'] = 0;
1359 $shortcode['[yaymail_order_id]'] = 1;
1360 $shortcode['[yaymail_order_link]'] = '<a href="" style="color:' . esc_attr( $text_link_color ) . ';">' . esc_html__( 'Order', 'yaymail' ) . '</a>';
1361 $shortcode['[yaymail_order_link_string]'] = esc_url( get_home_url() );
1362 $shortcode['[yaymail_order_number]'] = '1';
1363 $shortcode['[yaymail_order_refund]'] = 0;
1364 $shortcode['[yaymail_order_sub_total]'] = wc_price( '18.00' );
1365 $shortcode['[yaymail_order_discount]'] = wc_price( '18.00' );
1366 $shortcode['[yaymail_order_total]'] = wc_price( '18.00' );
1367 $shortcode['[yaymail_order_total_numbers]'] = '18.00';
1368 $shortcode['[yaymail_orders_count]'] = '1';
1369 $shortcode['[yaymail_quantity_count]'] = '1';
1370 $shortcode['[yaymail_orders_count_double]'] = '2';
1371
1372 // PAYMENTS
1373 $shortcode['[yaymail_order_payment_method]'] = esc_html__( 'Direct bank transfer', 'yaymail' );
1374 $shortcode['[yaymail_order_payment_url]'] = '<a href="">' . esc_html__( 'Payment page', 'yaymail' ) . '</a>';
1375 $shortcode['[yaymail_order_payment_url_string]'] = '';
1376 $shortcode['[yaymail_payment_instruction]'] = __( 'Payment Instructions', 'yaymail' );
1377 $shortcode['[yaymail_payment_method]'] = esc_html__( 'Check payments', 'yaymail' );
1378 $shortcode['[yaymail_transaction_id]'] = 1;
1379
1380 // SHIPPINGS
1381 $shortcode['[yaymail_order_shipping]'] = esc_html__( '333', 'yaymail' );
1382 $shortcode['[yaymail_shipping_address]'] = $shipping_address;
1383 $shortcode['[yaymail_shipping_address_1]'] = esc_html__( '755 E North Grove Rd', 'yaymail' );
1384 $shortcode['[yaymail_shipping_address_2]'] = esc_html__( '755 E North Grove Rd', 'yaymail' );
1385 $shortcode['[yaymail_shipping_city]'] = esc_html__( 'Mayville, Michigan', 'yaymail' );
1386 $shortcode['[yaymail_shipping_company]'] = esc_html__( 'YayCommerce', 'yaymail' );
1387 $shortcode['[yaymail_shipping_country]'] = '';
1388 $shortcode['[yaymail_shipping_first_name]'] = esc_html__( 'John', 'yaymail' );
1389 $shortcode['[yaymail_shipping_last_name]'] = esc_html__( 'John', 'yaymail' );
1390 $shortcode['[yaymail_shipping_method]'] = '';
1391 $shortcode['[yaymail_shipping_postcode]'] = esc_html__( '48744', 'yaymail' );
1392 $shortcode['[yaymail_shipping_state]'] = esc_html__( 'Random', 'yaymail' );
1393 $shortcode['[yaymail_shipping_phone]'] = esc_html__( '(910) 529-1147', 'yaymail' );
1394
1395 // BILLING
1396 $shortcode['[yaymail_billing_address]'] = $billing_address;
1397 $shortcode['[yaymail_billing_address_1]'] = esc_html__( '7400 Edwards Rd', 'yaymail' );
1398 $shortcode['[yaymail_billing_address_2]'] = esc_html__( '7400 Edwards Rd', 'yaymail' );
1399 $shortcode['[yaymail_billing_city]'] = esc_html__( 'Edwards Rd', 'yaymail' );
1400 $shortcode['[yaymail_billing_company]'] = esc_html__( 'YayCommerce', 'yaymail' );
1401 $shortcode['[yaymail_billing_country]'] = '';
1402 $shortcode['[yaymail_billing_email]'] = esc_html__( 'johndoe@gmail.com', 'yaymail' );
1403 $shortcode['[yaymail_billing_first_name]'] = esc_html__( 'John', 'yaymail' );
1404 $shortcode['[yaymail_billing_last_name]'] = esc_html__( 'Doe', 'yaymail' );
1405 $shortcode['[yaymail_billing_phone]'] = esc_html__( '(910) 529-1147', 'yaymail' );
1406 $shortcode['[yaymail_billing_postcode]'] = esc_html__( '48744', 'yaymail' );
1407 $shortcode['[yaymail_billing_state]'] = esc_html__( 'Random', 'yaymail' );
1408
1409 // RESET PASSWORD:
1410 $shortcode['[yaymail_password_reset_url]'] = '<a style="color:' . esc_attr( $text_link_color ) . ';" href="">' . esc_html__( 'Click here to reset your password', 'woocommerce' ) . '</a>';
1411 $shortcode['[yaymail_password_reset_url_string]'] = esc_url( get_home_url() ) . '/my-account/lost-password/?login';
1412 $shortcode['[yaymail_wp_password_reset_url]'] = esc_url( get_home_url() ) . '/my-account/lost-password/?login';
1413
1414 // NEW USERS:
1415 $shortcode['[yaymail_user_new_password]'] = esc_html__( 'G(UAM1(eIX#G', 'yaymail' );
1416 $shortcode['[yaymail_set_password_url_string]'] = esc_url( get_home_url() ) . '/my-account/set-password/';
1417 $shortcode['[yaymail_user_activation_link]'] = '';
1418
1419 // GENERALS
1420 $shortcode['[yaymail_customer_note]'] = esc_html__( 'note', 'yaymail' );
1421 $shortcode['[yaymail_customer_notes]'] = esc_html__( 'notes', 'yaymail' );
1422 $shortcode['[yaymail_customer_provided_note]'] = esc_html__( 'provided note', 'yaymail' );
1423 $shortcode['[yaymail_site_name]'] = esc_html( get_bloginfo( 'name' ) );
1424 $shortcode['[yaymail_site_url]'] = '<a style="color: ' . esc_attr( $text_link_color ) . ';" href="' . esc_url( get_home_url() ) . '"> ' . esc_url( get_home_url() ) . ' </a>';
1425 $shortcode['[yaymail_site_url_string]'] = esc_url( get_home_url() );
1426 $shortcode['[yaymail_user_email]'] = $current_user->data->user_email;
1427 $shortcode['[yaymail_user_id]'] = $user_id;
1428 $shortcode['[yaymail_customer_username]'] = $current_user->data->user_login;
1429 $shortcode['[yaymail_customer_roles]'] = implode( ', ', $current_user->roles );
1430 $shortcode['[yaymail_customer_name]'] = get_user_meta( $current_user->data->ID, 'first_name', true ) . ' ' . get_user_meta( $current_user->data->ID, 'last_name', true );
1431 $shortcode['[yaymail_customer_first_name]'] = get_user_meta( $current_user->data->ID, 'first_name', true );
1432 $shortcode['[yaymail_customer_last_name]'] = get_user_meta( $current_user->data->ID, 'last_name', true );
1433 $shortcode['[yaymail_view_order_url]'] = '';
1434 $shortcode['[yaymail_view_order_url_string]'] = '';
1435 $shortcode['[yaymail_billing_shipping_address]'] = $this->billingShippingAddress( '', $this->order ); // done
1436
1437 $shortcode['[yaymail_billing_shipping_address_title]'] = $this->billingShippingAddressTitle( '', $this->order ); // done
1438 $shortcode['[yaymail_billing_shipping_address_content]'] = $this->billingShippingAddressContent( '', $this->order ); // done
1439 $shortcode['[yaymail_check_billing_shipping_address]'] = $this->checkBillingShippingAddress( '', $this->order ); // done
1440
1441 $shortcode['[yaymail_domain]'] = parse_url( get_site_url() )['host'];
1442 $shortcode['[yaymail_user_account_url]'] = '<a style="color:' . esc_attr( $text_link_color ) . '; font-weight: normal; text-decoration: underline;" href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '">' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '</a>';
1443 $shortcode['[yaymail_user_account_url_string]'] = esc_url( wc_get_page_permalink( 'myaccount' ) );
1444 $shortcode['[yaymail_order_coupon_codes]'] = esc_html__( 'yaymail_code', 'yaymail' );
1445
1446 //Support shortcode for WooCommerce for LatePoint
1447 if ( class_exists( 'TechXelaLatePointPaymentsWooCommerce' ) ) {
1448 $shortcode['[yaymail_woo_latepoint_booking_detail]'] = WooLatepoint::wooLatepointBookingDetail( '', $this->order, false );
1449
1450 $shortcode['[yaymail_woo_latepoint_caption]'] = WooLatepoint::wooLatepointCaption( '', $this->order, false );
1451 $shortcode['[yaymail_woo_latepoint_bg_color]'] = WooLatepoint::wooLatepointBgColor( '', $this->order, false );
1452 $shortcode['[yaymail_woo_latepoint_text_color]'] = WooLatepoint::wooLatepointTextColor( '', $this->order, false );
1453 $shortcode['[yaymail_woo_latepoint_font_size]'] = WooLatepoint::wooLatepointFontSize( '', $this->order, false );
1454 $shortcode['[yaymail_woo_latepoint_border]'] = WooLatepoint::wooLatepointBorder( '', $this->order, false );
1455 $shortcode['[yaymail_woo_latepoint_border_radius]'] = WooLatepoint::wooLatepointBorderRadius( '', $this->order, false );
1456 $shortcode['[yaymail_woo_latepoint_margin]'] = WooLatepoint::wooLatepointMargin( '', $this->order, false );
1457 $shortcode['[yaymail_woo_latepoint_padding]'] = WooLatepoint::wooLatepointPaddings( '', $this->order, false );
1458 $shortcode['[yaymail_woo_latepoint_css]'] = WooLatepoint::wooLatepointCss( '', $this->order, false );
1459 $shortcode['[yaymail_woo_latepoint_show_locations]'] = WooLatepoint::wooLatepointShowLocations( '', $this->order, false );
1460 $shortcode['[yaymail_woo_latepoint_show_agents]'] = WooLatepoint::wooLatepointShowAgents( '', $this->order, false );
1461 $shortcode['[yaymail_woo_latepoint_show_services]'] = WooLatepoint::wooLatepointShowServices( '', $this->order, false );
1462 $shortcode['[yaymail_woo_latepoint_show_service_categories]'] = WooLatepoint::wooLatepointShowServiceCategories( '', $this->order, false );
1463
1464 $shortcode['[yaymail_woo_latepoint_selected_location]'] = WooLatepoint::wooLatepointSelectedLocation( '', $this->order, false );
1465 $shortcode['[yaymail_woo_latepoint_selected_agent]'] = WooLatepoint::wooLatepointSelectedAgent( '', $this->order, false );
1466 $shortcode['[yaymail_woo_latepoint_selected_service]'] = WooLatepoint::wooLatepointSelectedService( '', $this->order, false );
1467 $shortcode['[yaymail_woo_latepoint_selected_service_category]'] = WooLatepoint::wooLatepointSelectedServiceCategory( '', $this->order, false );
1468 $shortcode['[yaymail_woo_latepoint_selected_duration]'] = WooLatepoint::wooLatepointSelectedDuration( '', $this->order, false );
1469 $shortcode['[yaymail_woo_latepoint_selected_total_attendees]'] = WooLatepoint::wooLatepointSelectedTotalAttendees( '', $this->order, false );
1470
1471 $shortcode['[yaymail_woo_latepoint_calendar_start_date]'] = WooLatepoint::wooLatepointCalendarStartDate( '', $this->order, false );
1472 $shortcode['[yaymail_woo_latepoint_hide_side_panel]'] = WooLatepoint::wooLatepointHideSidePanel( '', $this->order, false );
1473 $shortcode['[yaymail_woo_latepoint_hide_summary]'] = WooLatepoint::wooLatepointHideSummary( '', $this->order, false );
1474 }
1475
1476 // ADDITIONAL ORDER META:
1477 $order = CustomPostType::getListOrders();
1478 $order_metaArr = get_post_meta( isset( $order[0]['id'] ) ? $order[0]['id'] : '' );
1479 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
1480 foreach ( $order_metaArr as $k => $v ) {
1481 $nameField = str_replace( ' ', '_', trim( $k ) );
1482 $nameShorcode = '[yaymail_post_meta:' . $nameField . ']';
1483
1484 // when array $v has tow value ???
1485 if ( is_array( $v ) && count( $v ) > 0 ) {
1486 $shortcode[ $nameShorcode ] = trim( $v[0] );
1487 } else {
1488 $shortcode[ $nameShorcode ] = trim( $v );
1489 }
1490 }
1491 }
1492
1493 $this->order_data = $shortcode;
1494 }
1495
1496 public function ordetItemTables( $order, $default_args ) {
1497 $is_preview = Helper::isPreview( $this->preview_mail );
1498 $postID = CustomPostType::postIDByTemplate( $this->template );
1499 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
1500 $items = $order->get_items();
1501 if ( $is_preview ) {
1502 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-items-preview.php';
1503 } else {
1504 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-items.php';
1505 }
1506
1507 $yaymail_settings = get_option( 'yaymail_settings' );
1508
1509 $show_product_image = isset( $yaymail_settings['product_image'] ) ? $yaymail_settings['product_image'] : 0;
1510 $show_product_sku = isset( $yaymail_settings['product_sku'] ) ? $yaymail_settings['product_sku'] : 0;
1511 $show_product_des = isset( $yaymail_settings['product_des'] ) ? $yaymail_settings['product_des'] : 0;
1512 $default_args['image_size'][0] = isset( $yaymail_settings['image_width'] ) ? $yaymail_settings['image_width'] : 32;
1513 $default_args['image_size'][1] = isset( $yaymail_settings['image_height'] ) ? $yaymail_settings['image_height'] : 32;
1514 $default_args['image_size'][2] = isset( $yaymail_settings['image_size'] ) ? $yaymail_settings['image_size'] : 'thumbnail';
1515
1516 $args = array(
1517 'order' => $order,
1518 'items' => $order->get_items(),
1519 'show_download_links' => $order->is_download_permitted() && ! $default_args['sent_to_admin'],
1520 'show_sku' => $show_product_sku,
1521 'show_des' => $show_product_des,
1522 'show_purchase_note' => $order->is_paid() && ! $default_args['sent_to_admin'],
1523 'show_image' => $show_product_image,
1524 'image_size' => $default_args['image_size'],
1525 'plain_text' => $default_args['plain_text'],
1526 'sent_to_admin' => $default_args['sent_to_admin'],
1527 'order_item_table_border_color' => isset( $yaymail_settings['background_color_table_items'] ) ? $yaymail_settings['background_color_table_items'] : '#dddddd',
1528 'text_link_color' => $text_link_color,
1529 );
1530 include $path;
1531 }
1532 public function itemsBorder( $atts, $order, $sent_to_admin = '' ) {
1533 if ( null === $order ) {
1534 ob_start();
1535 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details-border.php';
1536 include $path;
1537 $html = ob_get_contents();
1538 ob_end_clean();
1539 return $html;
1540 } else {
1541 ob_start();
1542 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border.php';
1543 include $path;
1544 $html = ob_get_contents();
1545 ob_end_clean();
1546 return $html;
1547 }
1548
1549 }
1550
1551 /* Link Downloadable Product - start */
1552 public function itemsDownloadableTitle( $atts, $order, $sent_to_admin = '', $items = array() ) {
1553 if ( null !== $order ) {
1554 $items = $order->get_items();
1555 $downloads = $order->get_downloadable_items();
1556 }
1557 ob_start();
1558 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-item-download-title.php';
1559 include $path;
1560 $html = ob_get_contents();
1561 ob_end_clean();
1562 return $html;
1563 }
1564 public function itemsDownloadableProduct( $atts, $order, $sent_to_admin = '', $items = array() ) {
1565 if ( null === $order ) {
1566 ob_start();
1567 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-item-download.php';
1568 include $path;
1569 $html = ob_get_contents();
1570 ob_end_clean();
1571 return $html;
1572 } else {
1573 if ( class_exists( 'WC_Subscription' ) ) {
1574 add_filter(
1575 'woocommerce_order_is_download_permitted',
1576 function( $value ) {
1577 return true;
1578 },
1579 100
1580 );
1581 }
1582
1583 $items = $order->get_items();
1584 ob_start();
1585 $downloads = $order->get_downloadable_items();
1586 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-item-download.php';
1587 include $path;
1588 $html = ob_get_contents();
1589 ob_end_clean();
1590 return $html;
1591 }
1592 }
1593
1594 /* Order items border - start */
1595 public function itemsBorderBefore( $atts, $order, $sent_to_admin = '' ) {
1596 if ( null === $order ) {
1597 return '';
1598 } else {
1599 ob_start();
1600 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-before.php';
1601 include $path;
1602 $html = ob_get_contents();
1603 ob_end_clean();
1604 return $html;
1605 }
1606 }
1607
1608 public function itemsBorderAfter( $atts, $order, $sent_to_admin = '' ) {
1609 if ( null === $order ) {
1610 return '';
1611 } else {
1612 ob_start();
1613 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-after.php';
1614 include $path;
1615 $html = ob_get_contents();
1616 ob_end_clean();
1617 return $html;
1618 }
1619 }
1620
1621 public function itemsBorderTitle( $atts, $order, $sent_to_admin = '' ) {
1622 if ( null === $order ) {
1623 ob_start();
1624 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details-border-title.php';
1625 include $path;
1626 $html = ob_get_contents();
1627 ob_end_clean();
1628 return $html;
1629 } else {
1630 ob_start();
1631 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-title.php';
1632 include $path;
1633 $html = ob_get_contents();
1634 ob_end_clean();
1635 return $html;
1636 }
1637 }
1638
1639 public function itemsBorderContent( $atts, $order, $sent_to_admin = '' ) {
1640 if ( null === $order ) {
1641 ob_start();
1642 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details-border-content.php';
1643 include $path;
1644 $html = ob_get_contents();
1645 ob_end_clean();
1646 return $html;
1647 } else {
1648 ob_start();
1649 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-content.php';
1650 include $path;
1651 $html = ob_get_contents();
1652 ob_end_clean();
1653 return $html;
1654 }
1655 }
1656 /* Order items border - end */
1657
1658 public function billingShippingAddress( $atts, $order ) {
1659 $postID = CustomPostType::postIDByTemplate( $this->template );
1660 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
1661 if ( null !== $order ) {
1662 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
1663 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
1664 if ( $order->get_billing_phone() ) {
1665 $billing_address .= "<br/> <a href='tel:" . esc_html( $order->get_billing_phone() ) . "' style='color:" . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_phone() ) . '</a>';
1666 }
1667 if ( $order->get_billing_email() ) {
1668 $billing_address .= "<br/><a href='mailto:" . esc_html( $order->get_billing_email() ) . "' style='color:" . esc_attr( $text_link_color ) . ";font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_email() ) . '</a>';
1669 }
1670 } else {
1671 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1672 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1673 }
1674 ob_start();
1675 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-billing-shipping-address.php';
1676 $order = $this->order;
1677 include $path;
1678 $html = ob_get_contents();
1679 ob_end_clean();
1680 return $html;
1681
1682 }
1683
1684 /* Billing Shipping Address - start */
1685 public function billingShippingAddressTitle( $atts, $order ) {
1686 $postID = CustomPostType::postIDByTemplate( $this->template );
1687 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
1688 if ( null !== $order ) {
1689 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
1690 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
1691 } else {
1692 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1693 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1694 }
1695 ob_start();
1696 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-billing-shipping-address-title.php';
1697 $order = $this->order;
1698 include $path;
1699 $html = ob_get_contents();
1700 ob_end_clean();
1701 return $html;
1702 }
1703
1704 public function checkBillingShippingAddress( $atts, $order_id ) {
1705 $isShippingAddress = false;
1706 $isBillingAddress = false;
1707
1708 if ( ! empty( $billing_address ) ) {
1709 $isBillingAddress = true;
1710 }
1711 if ( ! empty( $shipping_address ) ) {
1712 $isShippingAddress = true;
1713 }
1714
1715 $args = array(
1716 'isShippingAddress' => $isShippingAddress,
1717 'isBillingAddress' => $isBillingAddress,
1718 );
1719
1720 return 'Checking_here';
1721 }
1722
1723 public function billingShippingAddressContent( $atts, $order ) {
1724 $postID = CustomPostType::postIDByTemplate( $this->template );
1725 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#7f54b3';
1726 $is_preview = Helper::isPreview( $this->preview_mail );
1727 if ( $is_preview ) {
1728 if ( null !== $order ) {
1729 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
1730 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
1731 } else {
1732 $billing_address = 'John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/>';
1733 $shipping_address = 'John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/>';
1734 }
1735 ob_start();
1736 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-billing-shipping-address-content-preview.php';
1737 $order = $this->order;
1738 include $path;
1739 $html = ob_get_contents();
1740 ob_end_clean();
1741 return $html;
1742 } else {
1743 if ( null !== $order ) {
1744 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
1745 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
1746 if ( $order->get_billing_phone() ) {
1747 $billing_address .= "<br/> <a href='tel:" . esc_html( $order->get_billing_phone() ) . "' style='color:" . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_phone() ) . '</a>';
1748 }
1749 if ( $order->get_billing_email() ) {
1750 $billing_address .= "<br/><a href='mailto:" . esc_html( $order->get_billing_email() ) . "' style='color:" . esc_attr( $text_link_color ) . ";font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_email() ) . '</a>';
1751 }
1752 if ( method_exists( $order, 'get_shipping_phone' ) && ! empty( $order->get_shipping_phone() ) ) {
1753 if ( ! str_contains( $shipping_address, $order->get_shipping_phone() ) ) {
1754 $shipping_address .= "<br/> <a href='tel:" . esc_html( $order->get_shipping_phone() ) . "' style='color:" . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_shipping_phone() ) . '</a>';
1755 }
1756 }
1757 if ( metadata_exists( 'post', $order->get_id(), '_shipping_email' ) ) {
1758 if ( ! str_contains( $shipping_address, get_post_meta( $order->get_id(), '_shipping_email', true ) ) ) {
1759 $shipping_address .= "<br/><a href='mailto:" . esc_html( get_post_meta( $order->get_id(), '_shipping_email', true ) ) . "' style='color:" . esc_attr( $text_link_color ) . ";font-weight: normal; text-decoration: underline;'>" . esc_html( get_post_meta( $order->get_id(), '_shipping_email', true ) ) . '</a>';
1760 }
1761 }
1762 } else {
1763 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1764 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . esc_attr( $text_link_color ) . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1765 }
1766 ob_start();
1767 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-billing-shipping-address-content.php';
1768 $order = $this->order;
1769 include $path;
1770 $html = ob_get_contents();
1771 ob_end_clean();
1772 return $html;
1773 }
1774 }
1775 /* Billing Shipping Address - end */
1776
1777 public function orderItems( $items, $sent_to_admin = '', $checkOrder = '', $is_display = true ) {
1778 if ( 'sampleOrder' === $checkOrder ) {
1779 ob_start();
1780 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details.php';
1781 $order = $this->order;
1782 include $path;
1783 $html = ob_get_contents();
1784 ob_end_clean();
1785 return $html;
1786
1787 } else {
1788 ob_start();
1789 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details.php';
1790 $order = $this->order;
1791 include $path;
1792 $html = ob_get_contents();
1793 ob_end_clean();
1794 return $html;
1795 }
1796
1797 }
1798 public function getOrderCustomerNotes( $customerNotes ) {
1799 ob_start();
1800 foreach ( $customerNotes as $customerNote ) {
1801 ?>
1802
1803 <?php echo wp_kses_post( wpautop( wptexturize( make_clickable( $customerNote->comment_content ) ) ) ); ?>
1804
1805 <?php
1806 }
1807 $html = ob_get_contents();
1808 ob_end_clean();
1809 return $html;
1810 }
1811
1812 /* Woocommerce Hook - End */
1813
1814 public function woocommerceEmailOrderMeta( $attr, $sent_to_admin = '', $checkOrder = '', $args = '' ) {
1815 if ( 'sampleOrder' === $checkOrder ) {
1816 return '[woocommerce_email_order_meta]';
1817 } else {
1818 $order = $this->order;
1819 ob_start();
1820 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/wc-email-order-meta.php';
1821 include $path;
1822 $html = ob_get_contents();
1823 ob_end_clean();
1824 return $html;
1825 }
1826 }
1827
1828 public function woocommerceEmailOrderDetails( $attr, $sent_to_admin = '', $checkOrder = '', $args = '' ) {
1829 if ( 'sampleOrder' === $checkOrder ) {
1830 return '[woocommerce_email_order_details]';
1831 } else {
1832 $order = $this->order;
1833 ob_start();
1834 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/wc-email-order-detail.php';
1835 include $path;
1836 $html = ob_get_contents();
1837 ob_end_clean();
1838 return $html;
1839 }
1840 }
1841 public function woocommerceEmailBeforeOrderTable( $attr, $sent_to_admin = '', $checkOrder = '', $args = '' ) {
1842 if ( 'sampleOrder' === $checkOrder ) {
1843 return '[woocommerce_email_before_order_table]';
1844 } else {
1845 $order = $this->order;
1846 ob_start();
1847 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/wc-email-before.php';
1848 include $path;
1849 $html = ob_get_contents();
1850 ob_end_clean();
1851 return $html;
1852 }
1853 }
1854 public function woocommerceEmailAfterOrderTable( $attr, $sent_to_admin = '', $checkOrder = '', $args = '' ) {
1855 if ( 'sampleOrder' === $checkOrder ) {
1856 return '[woocommerce_email_after_order_table]';
1857 } else {
1858 $order = $this->order;
1859 ob_start();
1860 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/wc-email-after.php';
1861 include $path;
1862 $html = ob_get_contents();
1863 ob_end_clean();
1864 return $html;
1865 }
1866 }
1867 public function getHeading( $args, $order, $sent_to_admin ) {
1868 if ( isset( $args['email_heading'] ) && ! empty( $args ) ) {
1869 $email_heading = $args['email_heading'];
1870 } else {
1871 if ( isset( $order ) ) {
1872 $orderID = $order->get_id();
1873 $email_heading = 'Order Refunded: ' . $order->get_id();
1874 } else {
1875 $email_heading = 'Order Refunded: 1';
1876 }
1877 }
1878 return $email_heading;
1879 }
1880 public function orderCouponCodes( $args, $order ) {
1881 if ( isset( $order ) && method_exists( $order, 'get_coupon_codes' ) && ! empty( $order->get_coupon_codes() ) ) {
1882 $coupon_codes = $order->get_coupon_codes();
1883 ob_start();
1884 foreach ( $coupon_codes as $key => $value ) {
1885 ?>
1886 <?php echo wp_kses_post( $value ); ?>
1887 <?php
1888 }
1889 $html = ob_get_contents();
1890 ob_end_clean();
1891 return $html;
1892 }
1893
1894 }
1895 public function orderPaymentInstructions( $order, $sent_to_admin = false ) {
1896 if ( null === $order ) {
1897 return '';
1898 } else {
1899 ob_start();
1900 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-payment-gateways.php';
1901 include $path;
1902 $html = ob_get_contents();
1903 ob_end_clean();
1904 return $html;
1905 }
1906 }
1907
1908 }
1909