PluginProbe
YayMail – WooCommerce Email Customizer / 3.2.6
YayMail – WooCommerce Email Customizer v3.2.6
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 / includes / MailBuilder / Shortcodes.php

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

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