PluginProbe
YayMail – WooCommerce Email Customizer / 3.2.7.1
YayMail – WooCommerce Email Customizer v3.2.7.1
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
yaymail / includes / MailBuilder / Shortcodes.php

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

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