PluginProbe
YayMail – WooCommerce Email Customizer / 2.1.4
YayMail – WooCommerce Email Customizer v2.1.4
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 2.1.4, at includes/MailBuilder/Shortcodes.php

1,419 lines 63.1 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
10 defined( 'ABSPATH' ) || exit;
11 global $woocommerce, $wpdb, $current_user, $order;
12
13 class Shortcodes {
14
15 protected static $instance = null;
16 public $order_id = false;
17 public $args_email = false;
18 public $order;
19 public $sent_to_admin = false;
20 public $order_data;
21 public $template = false;
22 public $customer_note = false;
23 public $shipping_address = null;
24 public $billing_address = null;
25 // public $array_content_template = false;
26 public $shortcodes_lists;
27 public static function getInstance() {
28 if ( null == self::$instance ) {
29 self::$instance = new self();
30 }
31 return self::$instance;
32 }
33
34 public function __construct( $template = false, $checkOrder = '' ) {
35 if ( $template ) {
36 $this->template = $template;
37 if ( 'sampleOrder' === $checkOrder ) {
38 $this->shortCodesOrderSample();
39 } else {
40 $this->shortCodesOrderDefined();
41 }
42 // style css
43 add_filter( 'woocommerce_email_styles', array( $this, 'customCss' ) );
44
45 // Order Details
46 $order_details_list = array(
47 'items_downloadable_title',
48 'items_downloadable_product',
49 'items_border',
50 'items',
51 'order_date',
52 'order_fee',
53 'order_id',
54 'order_link',
55 'order_number',
56 'order_refund',
57 'order_sub_total',
58 'order_total',
59 'order_tn',
60 'items_border_before',
61 'items_border_after',
62 'items_border_title',
63 'items_border_content',
64 'items_downloadable_product',
65 'items_downloadable_title',
66 'woocommerce_email_before_order_table',
67 'woocommerce_email_after_order_table',
68 );
69
70 // Payments
71 $payments_list = array(
72 'order_payment_method',
73 'order_payment_url',
74 'order_payment_url_string',
75 'payment_method',
76 'transaction_id',
77 );
78
79 // Shippings
80 $shippings_list = array(
81 'order_shipping',
82 'shipping_address',
83 'shipping_address_1',
84 'shipping_address_2',
85 'shipping_city',
86 'shipping_company',
87 'shipping_country',
88 'shipping_first_name',
89 'shipping_last_name',
90 'shipping_method',
91 'shipping_postcode',
92 'shipping_state',
93 );
94
95 // Billings
96 $billings_list = array(
97 'billing_address',
98 'billing_address_1',
99 'billing_address_2',
100 'billing_city',
101 'billing_company',
102 'billing_country',
103 'billing_email',
104 'billing_first_name',
105 'billing_last_name',
106 'billing_phone',
107 'billing_postcode',
108 'billing_state',
109 );
110
111 // Reset Password
112 $reset_password_list = array( 'password_reset_url', 'password_reset_url_string' );
113
114 // New Users
115 $new_users_list = array( 'user_new_password', 'user_activation_link' );
116
117 // General
118 $general_list = array(
119 'customer_note',
120 'customer_notes',
121 'customer_provided_note',
122 'site_name',
123 'site_url',
124 'site_url_string',
125 'user_email',
126 'user_id',
127 'user_name',
128 'customer_username',
129 'customer_name',
130 'view_order_url',
131 'view_order_url_string',
132 'billing_shipping_address',
133 'domain',
134 'user_account_url',
135 'user_account_url_string',
136 // new
137 'billing_shipping_address_title',
138 'billing_shipping_address_content',
139 'check_billing_shipping_address',
140
141 );
142
143 // Additional Order Meta.
144 $order = CustomPostType::getListOrders();
145
146 /* Define Shortcodes */
147 $shortcodes_lists = array();
148 $shortcodes_lists = array_merge( $shortcodes_lists, apply_filters( 'yaymail_shortcodes', $shortcodes_lists ) );
149 $shortcodes_lists = array_merge( $shortcodes_lists, $order_details_list );
150 // $shortcodes_lists = array_merge( $shortcodes_lists, $order_subscription_list );
151 $shortcodes_lists = array_merge( $shortcodes_lists, $payments_list );
152 $shortcodes_lists = array_merge( $shortcodes_lists, $shippings_list );
153 $shortcodes_lists = array_merge( $shortcodes_lists, $billings_list );
154 $shortcodes_lists = array_merge( $shortcodes_lists, $reset_password_list );
155 $shortcodes_lists = array_merge( $shortcodes_lists, $new_users_list );
156 $shortcodes_lists = array_merge( $shortcodes_lists, $general_list );
157 $this->shortcodes_lists = $shortcodes_lists;
158 foreach ( $this->shortcodes_lists as $key => $shortcode_name ) {
159 if ( 'woocommerce_email_before_order_table' == $shortcode_name || 'woocommerce_email_after_order_table' == $shortcode_name ) {
160 add_shortcode( $shortcode_name, array( $this, 'shortcodeCallBack' ) );
161 } else {
162 $function_name = $this->parseShortCodeToFunctionName( 'yaymail_' . $shortcode_name );
163 if ( method_exists( $this, $function_name ) ) {
164 add_shortcode(
165 'yaymail_' . $shortcode_name,
166 function ( $atts, $content, $tag ) {
167 $function_name = $this->parseShortCodeToFunctionName( $tag );
168 return $this->$function_name( $atts, $this->order, $this->sent_to_admin, $this->args_email );
169 }
170 );
171 } elseif ( strpos( $shortcode_name, 'addon' ) !== false ) {
172 add_shortcode(
173 $shortcode_name,
174 function ( $atts, $content, $tag ) {
175 return $this->order_data[ '[' . $tag . ']' ];
176 }
177 );
178 } else {
179 add_shortcode( 'yaymail_' . $shortcode_name, array( $this, 'shortcodeCallBack' ) );
180 }
181 }
182 }
183
184 // add_shortcode( 'yaymail_billing_shipping_address_content', array( $this, 'billing_shipping_address_content' ) );
185 // add_shortcode( 'yaymail_items_border_content', array( $this, 'items_border_content' ) );
186 // add_shortcode( 'yaymail_items_border_title', array( $this, 'items_border_title' ) );
187 }
188 }
189
190 public function parseShortCodeToFunctionName( $shortcode_name ) {
191 $function_name = substr( $shortcode_name, 8 );
192 $offset = 0;
193 while ( false !== strpos( $function_name, '_', $offset ) ) {
194 $position = strpos( $function_name, '_', $offset );
195 $function_name[ $position + 1 ] = strtoupper( $function_name[ $position + 1 ] );
196 $offset = $position + 1;
197 }
198 $function_name = str_replace( '_', '', $function_name );
199 return $function_name;
200 }
201
202 public function applyCSSFormat( $defaultsCss = '' ) {
203 $templateEmail = \YayMail\Templates\Templates::getInstance();
204 $css = $templateEmail::getCssFortmat();
205 $cssDirection = '';
206 $cssDirection .= 'td{direction: rtl}';
207 $cssDirection .= 'td, th, td{text-align:right;}';
208
209 $css .= get_option( 'yaymail_direction' ) && get_option( 'yaymail_direction' ) === 'rtl' ? $cssDirection : '';
210 $css .= $defaultsCss;
211 $css .= '.td { color: inherit; }';
212 return $css;
213 }
214 public function customCss( $css = '' ) {
215 return $this->applyCSSFormat( $css );
216 }
217 public function setOrderId( $order_id = '', $sent_to_admin = '', $args = '' ) {
218 $this->order_id = $order_id;
219 $this->args_email = $args;
220 $this->sent_to_admin = $sent_to_admin;
221 // Additional Order Meta.
222 $order_meta_list = array();
223 if ( ! empty( $this->order_id ) ) {
224 $order_metaArr = get_post_meta( $this->order_id );
225 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
226 foreach ( $order_metaArr as $k => $v ) {
227 $nameField = str_replace( ' ', '_', trim( $k ) );
228 $order_meta_list[] = 'order_meta:' . $nameField;
229 }
230 }
231 }
232 $shortcodes_lists = array();
233 $shortcodes_lists = array_merge( $shortcodes_lists, $order_meta_list );
234 foreach ( $shortcodes_lists as $key => $shortcode_name ) {
235 add_shortcode( 'yaymail_' . $shortcode_name, array( $this, 'shortcodeCallBack' ) );
236 }
237 }
238
239 protected function _shortcode_atts( $defaults = array(), $atts = array() ) {
240 if ( isset( $atts['class'] ) ) {
241 $atts['classname'] = $atts['class'];
242 }
243
244 return \shortcode_atts( $defaults, $atts );
245 }
246
247 // short Codes Order when select SampleOrder
248 public function shortCodesOrderSample( $sent_to_admin = '' ) {
249 $user = wp_get_current_user();
250 $useId = get_current_user_id();
251 $this->defaultSampleOrderData( $sent_to_admin );
252 }
253
254 public function shortCodesOrderDefined( $sent_to_admin = '', $args = array() ) {
255 // if ( false === $this->order_id && class_exists( 'WC_Order' ) ) {
256 // $this->shortCodesOrderSample( $sent_to_admin );
257 // }
258 if ( false !== $this->order_id && ! empty( $this->order_id ) && class_exists( 'WC_Order' ) ) {
259 $this->order = new \WC_Order( $this->order_id );
260 $this->collectOrderData( $sent_to_admin, $args );
261 }
262 if ( ! function_exists( 'get_user_by' ) ) {
263 return false;
264 }
265 $action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : '';
266 if ( empty( $this->order_id ) || ! $this->order_id ) {
267 $shortcode = $this->order_data;
268 if ( isset( $_REQUEST['billing_email'] ) ) {
269 $shortcode['[yaymail_user_email]'] = sanitize_email( $_REQUEST['billing_email'] );
270 $user = get_user_by( 'email', sanitize_email( $_REQUEST['billing_email'] ) );
271 if ( ! empty( $user ) ) {
272 $shortcode['[yaymail_customer_username]'] = $user->user_login;
273 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
274 $shortcode['[yaymail_user_id]'] = $user->ID;
275 }
276 }
277 if ( empty( $shortcode['[yaymail_customer_username]'] ) ) {
278 if ( isset( $_REQUEST['user_email'] ) ) {
279 $user = get_user_by( 'email', sanitize_email( $_REQUEST['user_email'] ) );
280 if ( isset( $user->user_login ) ) {
281 $shortcode['[yaymail_customer_username]'] = $user->user_login;
282 }
283 if ( isset( $user->ID ) ) {
284 $shortcode['[yaymail_user_id]'] = $user->ID;
285 }
286 } elseif ( isset( $_REQUEST['email'] ) ) {
287 $user = get_user_by( 'email', sanitize_email( $_REQUEST['email'] ) );
288 if ( isset( $user->user_login ) ) {
289 $shortcode['[yaymail_customer_username]'] = $user->user_login;
290 }
291 if ( isset( $user->ID ) ) {
292 $shortcode['[yaymail_user_id]'] = $user->ID;
293 }
294 }
295 }
296 if ( empty( $shortcode['[yaymail_user_email]'] ) ) {
297 if ( isset( $_REQUEST['user_email'] ) ) {
298 $user = get_user_by( 'email', sanitize_email( $_REQUEST['user_email'] ) );
299 if ( isset( $user->user_email ) ) {
300 $shortcode['[yaymail_user_email]'] = $user->user_email;
301 }
302 if ( isset( $user->ID ) ) {
303 $shortcode['[yaymail_user_id]'] = $user->ID;
304 }
305 } elseif ( isset( $_REQUEST['email'] ) ) {
306 $user = get_user_by( 'email', sanitize_email( $_REQUEST['email'] ) );
307 if ( isset( $user->user_email ) ) {
308 $shortcode['[yaymail_user_email]'] = $user->user_email;
309 }
310 if ( isset( $user->ID ) ) {
311 $shortcode['[yaymail_user_id]'] = $user->ID;
312 }
313 }
314 }
315 if ( empty( $shortcode['[yaymail_customer_name]'] ) ) {
316 if ( isset( $_REQUEST['user_email'] ) ) {
317 $user = get_user_by( 'email', sanitize_email( $_REQUEST['user_email'] ) );
318 if ( isset( $user->user_email ) ) {
319 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
320 }
321 if ( isset( $user->ID ) ) {
322 $shortcode['[yaymail_user_id]'] = $user->ID;
323 }
324 } elseif ( isset( $_REQUEST['email'] ) ) {
325 $user = get_user_by( 'email', sanitize_email( $_REQUEST['email'] ) );
326 if ( isset( $user->user_email ) ) {
327 if ( ! empty( get_user_meta( $user->ID, 'first_name', true ) ) && ! empty( get_user_meta( $user->ID, 'last_name', true ) ) ) {
328 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
329 } elseif ( isset( $_REQUEST['first_name'] ) && isset( $_REQUEST['last_name'] ) ) {
330 $shortcode['[yaymail_customer_name]'] = sanitize_text_field( $_REQUEST['first_name'] ) . ' ' . sanitize_text_field( $_REQUEST['last_name'] );
331 }
332 }
333 if ( isset( $user->ID ) ) {
334 $shortcode['[yaymail_user_id]'] = $user->ID;
335 }
336 }
337 }
338 if ( ! empty( $args ) ) {
339 if ( isset( $args['email'] ) || isset( $args['admin_email'] ) || isset( $args['user'] ) ) {
340 $postID = CustomPostType::postIDByTemplate( $this->template );
341 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A';
342 $yaymail_settings = get_option( 'yaymail_settings' );
343 $yaymail_informations = array(
344 'post_id' => $postID,
345 'template' => $this->template,
346 'yaymail_elements' => get_post_meta( $postID, '_yaymail_elements', true ),
347 'general_settings' => array(
348 'tableWidth' => $yaymail_settings['container_width'],
349 'emailBackgroundColor' => get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : '#ECECEC',
350 'textLinkColor' => get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A',
351 ),
352 );
353 if ( isset( $args['email']->id ) && 'customer_reset_password' == $args['email']->id ) {
354 $user = new \WP_User( intval( $args['email']->user_id ) );
355 $shortcode['[yaymail_customer_username]'] = $args['email']->user_login;
356 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
357 $shortcode['[yaymail_user_email]'] = $args['email']->user_email;
358 $shortcode['[yaymail_user_id]'] = $user->ID;
359 $reset_key = get_password_reset_key( $user );
360 $resetURL = esc_url(
361 add_query_arg(
362 array(
363 'key' => $reset_key,
364 'login' => rawurlencode( $args['email']->user_login ),
365 ),
366 wc_get_endpoint_url( 'lost-password', '', wc_get_page_permalink( 'myaccount' ) )
367 )
368 );
369 $shortcode['[yaymail_password_reset_url]'] = '<a style="color: ' . $text_link_color . ';" href="' . esc_url( $resetURL ) . '">' . esc_html__( 'Click here to reset your password', 'woocommerce' ) . '</a>';
370 $shortcode['[yaymail_password_reset_url_string]'] = esc_url( $resetURL );
371 $shortcode['[yaymail_site_name]'] = get_bloginfo( 'name' );
372 }
373
374 $shortcode['[yaymail_site_name]'] = get_bloginfo( 'name' );
375 $shortcode['[yaymail_site_url]'] = '<a href="' . get_site_url() . '"> ' . get_site_url() . ' </a>';
376 $shortcode['[yaymail_site_url_string]'] = get_site_url();
377 $shortcode['[yaymail_user_account_url]'] = '<a style="color:' . $text_link_color . '; font-weight: normal; text-decoration: underline;" href="' . wc_get_page_permalink( 'myaccount' ) . '">' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '</a>';
378 $shortcode['[yaymail_user_account_url_string]'] = wc_get_page_permalink( 'myaccount' );
379 if ( isset( $args['email']->user_pass ) && ! empty( $args['email']->user_pass ) ) {
380 $shortcode['[yaymail_user_new_password]'] = $args['email']->user_pass;
381 } else {
382 if ( isset( $_REQUEST['pass1-text'] ) && '' != $_REQUEST['pass1-text'] ) {
383 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
384 } elseif ( isset( $_REQUEST['pass1'] ) && '' != $_REQUEST['pass1'] ) {
385 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
386 } else {
387 $shortcode['[yaymail_user_new_password]'] = '';
388 }
389 }
390 if ( isset( $args['email']->user_login ) && ! empty( $args['email']->user_login ) ) {
391 $shortcode['[yaymail_customer_username]'] = $args['email']->user_login;
392 $user = get_user_by( 'email', $args['email']->user_email );
393 if ( ! empty( get_user_meta( $user->ID, 'first_name', true ) ) && ! empty( get_user_meta( $user->ID, 'last_name', true ) ) ) {
394 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
395 } elseif ( isset( $_REQUEST['first_name'] ) && isset( $_REQUEST['last_name'] ) ) {
396 $shortcode['[yaymail_customer_name]'] = sanitize_text_field( $_REQUEST['first_name'] ) . ' ' . sanitize_text_field( $_REQUEST['last_name'] );
397 }
398 }
399 if ( isset( $args['email']->user_email ) && ! empty( $args['email']->user_email ) ) {
400 $shortcode['[yaymail_user_email]'] = $args['email']->user_email;
401 }
402 if ( isset( $args['email']->id ) && ( 'customer_new_account' == $args['email']->id || 'customer_new_account_activation' == $args['email']->id ) ) {
403 if ( 'customer_new_account_activation' == $args['email']->id ) {
404 if ( isset( $args['email']->user_activation_url ) && ! empty( $args['email']->user_activation_url ) ) {
405 $shortcode['[yaymail_user_activation_link]'] = $args['email']->user_activation_url;
406 }
407 } else {
408 if ( isset( $args['email']->user_login ) && ! empty( $args['email']->user_login ) ) {
409 global $wpdb, $wp_hasher;
410 $newHash = $wp_hasher;
411 // Generate something random for a password reset key.
412 $key = wp_generate_password( 20, false );
413
414 /**
415 *
416 * This action is documented in wp-login.php
417 */
418 do_action( 'retrieve_password_key', $args['email']->user_login, $key );
419
420 // Now insert the key, hashed, into the DB.
421 if ( empty( $wp_hasher ) ) {
422 if ( ! class_exists( 'PasswordHash' ) ) {
423 include_once ABSPATH . 'wp-includes/class-phpass.php';
424 }
425 $newHash = new \PasswordHash( 8, true );
426 }
427 $hashed = time() . ':' . $newHash->HashPassword( $key );
428 $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $args['email']->user_login ) );
429 $activation_url = network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $args['email']->user_login ), 'login' );
430 $shortcode['[yaymail_user_activation_link]'] = $activation_url;
431 }
432 }
433 }
434
435 // Define shortcode from plugin addon
436 $shortcode = apply_filters( 'yaymail_do_shortcode', $shortcode, $yaymail_informations, $args );
437 }
438 }
439
440 $this->order_data = $shortcode;
441 }
442 }
443 public function shortcodeCallBack( $atts, $content, $tag ) {
444
445 return isset( $this->order_data[ '[' . $tag . ']' ] ) ? $this->order_data[ '[' . $tag . ']' ] : false;
446
447 }
448
449 public function templateParser() {
450 // Helper::checkNonce();
451 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : '';
452 if ( ! wp_verify_nonce( $nonce, 'email-nonce' ) ) {
453 wp_send_json_error( array( 'mess' => 'Nonce is invalid' ) );
454 } else {
455 $request = $_POST;
456 $this->order_id = false;
457 if ( isset( $request['order_id'] ) ) {
458 $order_id = sanitize_text_field( $request['order_id'] );
459 if ( 'sampleOrder' !== $order_id ) {
460 $order_id = intval( $order_id );
461 }
462 if ( ! $order_id ) {
463 $order_id = '';
464 }
465
466 $this->template = isset( $request['template'] ) ? $request['template'] : false;
467 $this->order_id = $order_id;
468 }
469
470 if ( ! $this->order_id || ! $this->template ) {
471 return false;
472 }
473
474 if ( 'sampleOrder' !== $order_id ) {
475 $this->order = new \WC_Order( $this->order_id );
476 }
477
478 if ( 'sampleOrder' !== $order_id && ( is_null( $this->order ) || empty( $this->order ) || ! isset( $this->order ) ) ) {
479 return false;
480 }
481
482 if ( 'sampleOrder' !== $order_id ) {
483 $this->collectOrderData();
484 } else {
485 $this->defaultSampleOrderData();
486 }
487
488 $result = (object) array();
489 $result->order_id = $this->order_id;
490 $result->order_data = $this->order_data;
491
492 $shortcode_order_meta = array();
493 $shortcode_order_custom_meta = array();
494 if ( 'sampleOrder' !== $order_id ) {
495 $result->order = $this->order;
496 $result->order_items = $result->order->get_items();
497 $result->user_details = $result->order->get_user();
498
499 /*
500 @@@@ Get name field in custom field of order woocommerce.
501 */
502 $order_metaArr = get_post_meta( $order_id );
503 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
504 $pattern = '/^_.*/i';
505 $n = 0;
506 foreach ( $order_metaArr as $k => $v ) {
507 // @@@ starts with the "_" character of the woo field.
508 if ( ! preg_match( $pattern, $k ) ) {
509 $nameField = str_replace( ' ', '_', trim( $k ) );
510 $nameShorcode = '[yaymail_post_meta:' . $nameField . ']';
511 $key_order_meta = 'post_meta:' . $nameField . '_' . $n;
512 $shortcode_order_meta[] = array(
513 'key' => $key_order_meta,
514 $nameShorcode => 'Loads value of order meta key - ' . $nameField,
515 );
516 $n++;
517 }
518 }
519 }
520 if ( ! empty( $result->order ) ) {
521 foreach ( $result->order->get_meta_data() as $meta ) {
522 $nameField = str_replace( ' ', '_', trim( $meta->get_data()['key'] ) );
523 $nameShorcode = '[yaymail_order_meta:' . $nameField . ']';
524 $key_order_custom_meta = 'order_meta:' . $nameField;
525 $shortcode_order_custom_meta[] = array(
526 'key' => $key_order_custom_meta,
527 $nameShorcode => 'Loads value of order custom meta key - ' . $nameField,
528 );
529 }
530 }
531 } else {
532 $result->order = '';
533 $result->order_items = '';
534 $result->user_details = '';
535 }
536 $real_postID = '';
537 if ( isset( $request['template'] ) ) {
538 if ( CustomPostType::postIDByTemplate( $this->template ) ) {
539 $postID = CustomPostType::postIDByTemplate( $this->template );
540 $real_postID = $postID;
541 $emailTemplate = get_post( $postID );
542 $updateElement = new UpdateElement();
543 $yaymail_elements = get_post_meta( $postID, '_yaymail_elements', true );
544 $result->elements = Helper::unsanitize_array( $updateElement->merge_new_props_to_elements( $yaymail_elements ) );
545 $result->emailBackgroundColor = get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : 'rgb(236, 236, 236)';
546 $result->emailTextLinkColor = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A';
547 $result->titleShipping = get_post_meta( $postID, '_email_title_shipping', true ) ? get_post_meta( $postID, '_email_title_shipping', true ) : 'Shipping Address';
548 $result->titleBilling = get_post_meta( $postID, '_email_title_billing', true ) ? get_post_meta( $postID, '_email_title_billing', true ) : 'Billing Address';
549 $result->orderTitle = get_post_meta( $postID, '_yaymail_email_order_item_title', true );
550 $result->customCSS = $this->applyCSSFormat();
551 $result->shortcode_order_meta = $shortcode_order_meta;
552 $result->shortcode_order_custom_meta = $shortcode_order_custom_meta;
553 $result->follow_up_shortcodes = array();
554 }
555 }
556 // ob_start();
557 // do_action( 'YaymailAddonWooSubscriptionInformationVue', $result->order_id, $real_postID );
558 // $vueHtml = ob_get_contents();
559 // ob_end_clean();
560 // $result->wooAddonOrderSubscriptionTemp = $vueHtml;
561 if ( class_exists( 'Follow_Up_Emails' ) ) {
562 $result->follow_up_shortcodes = apply_filters( 'yaymail_follow_up_shortcode', array() );
563 }
564 $result->yaymailAddonTemps = apply_filters( 'yaymail_addon_templates', array(), $result->order, $real_postID );
565
566 echo json_encode( $result );
567 die();
568 }
569 }
570
571 public function collectOrderData( $sent_to_admin = '', $args = array() ) {
572 $order = $this->order;
573 if ( empty( $this->order_id ) || empty( $order ) ) {
574 return false;
575 }
576
577 // Getting Fee & Refunds:
578 $fee = 0;
579 $refund = 0;
580 $totals = $order->get_order_item_totals();
581 foreach ( $totals as $index => $value ) {
582 if ( strpos( $index, 'fee' ) !== false ) {
583 $fees = $order->get_fees();
584 foreach ( $fees as $feeVal ) {
585 if ( method_exists( $feeVal, 'get_amount' ) ) {
586 $fee += $feeVal->get_amount();
587 }
588 }
589 }
590 if ( strpos( $index, 'refund' ) !== false ) {
591 $refund = $order->get_total_refunded();
592 }
593 }
594 // User Info
595 $user_data = $order->get_user();
596 $created_date = $order->get_date_created();
597 $items = $order->get_items();
598 $yaymail_settings = get_option( 'yaymail_settings' );
599 $order_url = $order->get_edit_order_url();
600 if ( class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ) {
601 add_action(
602 'woocommerce_email_customer_details',
603 function( $order ) {
604 if ( 'Shortcodes.php' === basename( __FILE__ ) ) {
605 $this->shipping_address = $order->get_formatted_shipping_address();
606 $this->billing_address = $order->get_formatted_billing_address();
607 }
608 },
609 100,
610 1
611 );
612 ob_start();
613 do_action( 'woocommerce_email_customer_details', $order );
614 $delete_write = ob_get_contents();
615 ob_end_clean();
616 }
617 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
618 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
619 $postID = CustomPostType::postIDByTemplate( $this->template );
620 $yaymail_informations = array(
621 'post_id' => $postID,
622 'template' => $this->template,
623 'order' => $order,
624 'yaymail_elements' => get_post_meta( $postID, '_yaymail_elements', true ),
625 'general_settings' => array(
626 'tableWidth' => $yaymail_settings['container_width'],
627 'emailBackgroundColor' => get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : '#ECECEC',
628 'textLinkColor' => get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A',
629 ),
630 );
631 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A';
632 if ( $order->get_billing_phone() ) {
633 $billing_address .= "<br/> <a href='tel:" . esc_html( $order->get_billing_phone() ) . "' style='color:" . $text_link_color . "; font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_phone() ) . '</a>';
634 }
635 if ( $order->get_billing_email() ) {
636 $billing_address .= "<br/><a href='mailto:" . esc_html( $order->get_billing_email() ) . "' style='color:" . $text_link_color . ";font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_email() ) . '</a>';
637 }
638 $customerNotes = $order->get_customer_order_notes();
639 $customerNoteHtmlList = '';
640 $customerNoteHtml = $customerNoteHtmlList;
641 if ( ! empty( $customerNotes ) && count( $customerNotes ) ) {
642 $customerNoteHtmlList = $this->getOrderCustomerNotes( $customerNotes );
643 $customerNote_single[] = $customerNotes[0];
644 $customerNoteHtml = $this->getOrderCustomerNotes( $customerNote_single );
645 }
646
647 $resetURL = '';
648 if ( isset( $args['email']->reset_key ) && ! empty( $args['email']->reset_key )
649 && isset( $args['email']->user_login ) && ! empty( $args['email']->user_login )
650 ) {
651 $user = new \WP_User( intval( $args['email']->user_id ) );
652 $reset_key = get_password_reset_key( $user );
653 $resetURL = esc_url(
654 add_query_arg(
655 array(
656 'key' => $reset_key,
657 'login' => rawurlencode( $args['email']->user_login ),
658 ),
659 wc_get_endpoint_url( 'lost-password', '', wc_get_page_permalink( 'myaccount' ) )
660 )
661 );
662 }
663
664 // Link Downloadable Product
665 $shortcode['[yaymail_items_downloadable_title]'] = $this->itemsDownloadableTitle( '', $this->order, $sent_to_admin, '' ); // done
666 $shortcode['[yaymail_items_downloadable_product]'] = $this->itemsDownloadableProduct( '', $this->order, $sent_to_admin, '' ); // done
667
668 // ORDER DETAILS
669 $shortcode['[yaymail_items_border]'] = $this->itemsBorder( '', $this->order, $sent_to_admin ); // done
670 $shortcode['[yaymail_items_border_before]'] = $this->itemsBorderBefore( '', $this->order, $sent_to_admin ); // done
671 $shortcode['[yaymail_items_border_after]'] = $this->itemsBorderAfter( '', $this->order, $sent_to_admin ); // done
672 $shortcode['[yaymail_items_border_title]'] = $this->itemsBorderTitle( '', $this->order, $sent_to_admin ); // done
673 $shortcode['[yaymail_items_border_content]'] = $this->itemsBorderContent( '', $this->order, $sent_to_admin ); // done
674
675 // WC HOOK
676 $shortcode['[woocommerce_email_before_order_table]'] = $this->orderWoocommerceBeforeHook( $args, $sent_to_admin ); // not Changed
677 $shortcode['[woocommerce_email_after_order_table]'] = $this->orderWoocommerceAfterHook( $args, $sent_to_admin ); // not Changed
678
679 // Define shortcode from plugin addon
680 $shortcode = apply_filters( 'yaymail_do_shortcode', $shortcode, $yaymail_informations, $this->args_email );
681
682 $shortcode['[yaymail_items]'] = $this->orderItems( $items, $sent_to_admin );
683 if ( null != $created_date ) {
684 $shortcode['[yaymail_order_date]'] = $order->get_date_created()->date_i18n( wc_date_format() );
685 } else {
686 $shortcode['[yaymail_order_date]'] = '';
687 }
688 $shortcode['[yaymail_order_fee]'] = $fee;
689 if ( ! empty( $order->get_id() ) ) {
690 $shortcode['[yaymail_order_id]'] = $order->get_id();
691 } else {
692 $shortcode['[yaymail_order_id]'] = '';
693 }
694 $shortcode['[yaymail_order_link]'] = '<a href="' . $order_url . '" style="color:' . $text_link_color . ';">' . esc_html__( 'Order', 'yaymail' ) . '</a>';
695 $shortcode['[yaymail_order_link]'] = str_replace( '[yaymail_order_id]', $order->get_id(), $shortcode['[yaymail_order_link]'] );
696 if ( ! empty( $order->get_order_number() ) ) {
697 $shortcode['[yaymail_order_number]'] = $order->get_order_number();
698 } else {
699 $shortcode['[yaymail_order_number]'] = '';
700 }
701 $shortcode['[yaymail_order_refund]'] = $refund;
702 if ( isset( $totals['cart_subtotal']['value'] ) ) {
703 $shortcode['[yaymail_order_sub_total]'] = $totals['cart_subtotal']['value'];
704 } else {
705 $shortcode['[yaymail_order_sub_total]'] = '';
706 }
707 $shortcode['[yaymail_order_total]'] = wc_price( $order->get_total() );
708
709 // PAYMENTS
710 if ( isset( $totals['payment_method']['value'] ) ) {
711 $shortcode['[yaymail_order_payment_method]'] = $totals['payment_method']['value'];
712 } else {
713 $shortcode['[yaymail_order_payment_method]'] = '';
714 }
715 $shortcode['[yaymail_order_payment_url]'] = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Payment page', 'yaymail' ) . '</a>';
716 $shortcode['[yaymail_order_payment_url_string]'] = esc_url( $order->get_checkout_payment_url() );
717 if ( ! empty( $order->get_payment_method_title() ) ) {
718 $shortcode['[yaymail_payment_method]'] = $order->get_payment_method_title();
719 } else {
720 $shortcode['[yaymail_payment_method]'] = '';
721 }
722 if ( ! empty( $order->get_transaction_id() ) ) {
723 $shortcode['[yaymail_transaction_id]'] = $order->get_transaction_id();
724 } else {
725 $shortcode['[yaymail_transaction_id]'] = '';
726 }
727
728 // SHIPPINGS
729 if ( ! empty( $order->calculate_shipping() ) ) {
730 $shortcode['[yaymail_order_shipping]'] = $order->calculate_shipping();
731 } else {
732 $shortcode['[yaymail_order_shipping]'] = 0;
733 }
734 $shortcode['[yaymail_shipping_address]'] = $shipping_address;
735 if ( ! empty( $order->get_shipping_address_1() ) ) {
736 $shortcode['[yaymail_shipping_address_1]'] = $order->get_shipping_address_1();
737 } else {
738 $shortcode['[yaymail_shipping_address_1]'] = '';
739 }
740 if ( ! empty( $order->get_shipping_address_2() ) ) {
741 $shortcode['[yaymail_shipping_address_2]'] = $order->get_shipping_address_2();
742 } else {
743 $shortcode['[yaymail_shipping_address_2]'] = '';
744 }
745 if ( ! empty( $order->get_shipping_city() ) ) {
746 $shortcode['[yaymail_shipping_city]'] = $order->get_shipping_city();
747 } else {
748 $shortcode['[yaymail_shipping_city]'] = '';
749 }
750 if ( ! empty( $order->get_shipping_company() ) ) {
751 $shortcode['[yaymail_shipping_company]'] = $order->get_shipping_company();
752 } else {
753 $shortcode['[yaymail_shipping_company]'] = '';
754 }
755 if ( ! empty( $order->get_shipping_country() ) ) {
756 $shortcode['[yaymail_shipping_country]'] = $order->get_shipping_country();
757 } else {
758 $shortcode['[yaymail_shipping_country]'] = '';
759 }
760 if ( ! empty( $order->get_shipping_first_name() ) ) {
761 $shortcode['[yaymail_shipping_first_name]'] = $order->get_shipping_first_name();
762 } else {
763 $shortcode['[yaymail_shipping_first_name]'] = '';
764
765 }
766 if ( ! empty( $order->get_shipping_last_name() ) ) {
767 $shortcode['[yaymail_shipping_last_name]'] = $order->get_shipping_last_name();
768 } else {
769 $shortcode['[yaymail_shipping_last_name]'] = '';
770
771 }
772 if ( ! empty( $order->get_shipping_method() ) ) {
773 $shortcode['[yaymail_shipping_method]'] = $order->get_shipping_method();
774 } else {
775 $shortcode['[yaymail_shipping_method]'] = '';
776 }
777 if ( ! empty( $order->get_shipping_postcode() ) ) {
778 $shortcode['[yaymail_shipping_postcode]'] = $order->get_shipping_postcode();
779 } else {
780 $shortcode['[yaymail_shipping_postcode]'] = '';
781 }
782 if ( ! empty( $order->get_shipping_state() ) ) {
783 $shortcode['[yaymail_shipping_state]'] = $order->get_shipping_state();
784 } else {
785 $shortcode['[yaymail_shipping_state]'] = '';
786 }
787
788 // BILLINGS
789 $shortcode['[yaymail_billing_address]'] = $billing_address;
790 if ( ! empty( $order->get_billing_address_1() ) ) {
791 $shortcode['[yaymail_billing_address_1]'] = $order->get_billing_address_1();
792 } else {
793 $shortcode['[yaymail_billing_address_1]'] = '';
794 }
795 if ( ! empty( $order->get_billing_address_2() ) ) {
796 $shortcode['[yaymail_billing_address_2]'] = $order->get_billing_address_2();
797 } else {
798 $shortcode['[yaymail_billing_address_2]'] = '';
799 }
800 if ( ! empty( $order->get_billing_city() ) ) {
801 $shortcode['[yaymail_billing_city]'] = $order->get_billing_city();
802 } else {
803 $shortcode['[yaymail_billing_city]'] = $order->get_billing_city();
804 }
805 if ( ! empty( $order->get_billing_company() ) ) {
806 $shortcode['[yaymail_billing_company]'] = $order->get_billing_company();
807 } else {
808 $shortcode['[yaymail_billing_company]'] = '';
809 }
810 if ( ! empty( $order->get_billing_country() ) ) {
811 $shortcode['[yaymail_billing_country]'] = $order->get_billing_country();
812 } else {
813 $shortcode['[yaymail_billing_country]'] = '';
814 }
815 if ( ! empty( $order->get_billing_email() ) ) {
816 $shortcode['[yaymail_billing_email]'] = '<a style="color: inherit" href="mailto:' . $order->get_billing_email() . '">' . $order->get_billing_email() . '</a>';
817 } else {
818 $shortcode['[yaymail_billing_email]'] = '';
819 }
820 if ( ! empty( $order->get_billing_first_name() ) ) {
821 $shortcode['[yaymail_billing_first_name]'] = $order->get_billing_first_name();
822 } else {
823 $shortcode['[yaymail_billing_first_name]'] = '';
824 }
825 if ( ! empty( $order->get_billing_last_name() ) ) {
826 $shortcode['[yaymail_billing_last_name]'] = $order->get_billing_last_name();
827 } else {
828 $shortcode['[yaymail_billing_last_name]'] = '';
829 }
830 if ( ! empty( $order->get_billing_phone() ) ) {
831 $shortcode['[yaymail_billing_phone]'] = $order->get_billing_phone();
832 } else {
833 $shortcode['[yaymail_billing_phone]'] = '';
834 }
835 if ( ! empty( $order->get_billing_postcode() ) ) {
836 $shortcode['[yaymail_billing_postcode]'] = $order->get_billing_postcode();
837 } else {
838 $shortcode['[yaymail_billing_postcode]'] = '';
839 }
840 if ( ! empty( $order->get_billing_state() ) ) {
841 $shortcode['[yaymail_billing_state]'] = $order->get_billing_state();
842 } else {
843 $shortcode['[yaymail_billing_state]'] = '';
844 }
845
846 // Reset Passwords
847 $shortcode['[yaymail_password_reset_url]'] = '<a style="color: ' . $text_link_color . ';" href="' . esc_url( $resetURL ) . '">' . esc_html__( 'Click here to reset your password', 'woocommerce' ) . '</a>';
848 $shortcode['[yaymail_password_reset_url_string]'] = esc_url( $resetURL );
849
850 // New Users
851 if ( isset( $args['email']->user_pass ) && ! empty( $args['email']->user_pass ) ) {
852 $shortcode['[yaymail_user_new_password]'] = $args['email']->user_pass;
853 } else {
854 if ( isset( $_REQUEST['pass1-text'] ) && '' != $_REQUEST['pass1-text'] ) {
855 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
856 } elseif ( isset( $_REQUEST['pass1'] ) && '' != $_REQUEST['pass1'] ) {
857 $shortcode['[yaymail_user_new_password]'] = sanitize_text_field( $_REQUEST['pass1-text'] );
858 } else {
859 $shortcode['[yaymail_user_new_password]'] = '';
860 }
861 }
862 // Review this code ??
863 if ( isset( $args['email']->user_activation_url ) && ! empty( $args['email']->user_activation_url ) ) {
864 $shortcode['[yaymail_user_activation_link]'] = $args['email']->user_activation_url;
865 } else {
866 $shortcode['[yaymail_user_activation_link]'] = '';
867 }
868
869 // GENERALS
870 $shortcode['[yaymail_customer_note]'] = $customerNoteHtml;
871 $shortcode['[yaymail_customer_notes]'] = $customerNoteHtmlList;
872 if ( ! empty( $order->get_customer_note() ) ) {
873 $shortcode['[yaymail_customer_provided_note]'] = $order->get_customer_note();
874 } else {
875 $shortcode['[yaymail_customer_provided_note]'] = '';
876 }
877 $shortcode['[yaymail_site_name]'] = get_bloginfo( 'name' );
878 $shortcode['[yaymail_site_url]'] = '<a href="' . get_site_url() . '"> ' . get_site_url() . ' </a>';
879 $shortcode['[yaymail_site_url_string]'] = get_site_url();
880 if ( isset( $user_data->user_email ) ) {
881 $shortcode['[yaymail_user_email]'] = $user_data->user_email;
882 } else {
883 $shortcode['[yaymail_user_email]'] = $order->get_billing_email();
884 }
885 if ( isset( $shortcode['[yaymail_user_email]'] ) && '' != $shortcode['[yaymail_user_email]'] ) {
886 $user = get_user_by( 'email', $shortcode['[yaymail_user_email]'] );
887 $shortcode['[yaymail_user_id]'] = ( isset( $user->ID ) ) ? $user->ID : '';
888 }
889 if ( isset( $user_data->user_login ) && ! empty( $user_data->user_login ) ) {
890 $shortcode['[yaymail_customer_username]'] = $user_data->user_login;
891 } elseif ( isset( $user_data->user_nicename ) ) {
892 $shortcode['[yaymail_customer_username]'] = $user_data->user_nicename;
893 } else {
894 $shortcode['[yaymail_customer_username]'] = $order->get_billing_first_name();
895 }
896 if ( isset( $user->ID ) && ! empty( $user->ID ) ) {
897 $shortcode['[yaymail_customer_name]'] = get_user_meta( $user->ID, 'first_name', true ) . ' ' . get_user_meta( $user->ID, 'last_name', true );
898 } elseif ( isset( $user_data->user_nicename ) ) {
899 $shortcode['[yaymail_customer_name]'] = $user_data->user_nicename;
900 } else {
901 $shortcode['[yaymail_customer_name]'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
902 }
903 if ( ! empty( $order->get_view_order_url() ) ) {
904 $text_your_order = esc_html__( 'Your Order', 'yaymail' );
905 $shortcode['[yaymail_view_order_url]'] = '<a href="' . $order->get_view_order_url() . '" style="color:' . $text_link_color . ';">' . $text_your_order . '</a>';
906 $shortcode['[yaymail_view_order_url_string]'] = $order->get_view_order_url();
907 } else {
908 $shortcode['[yaymail_view_order_url]'] = '';
909 }
910 $shortcode['[yaymail_billing_shipping_address]'] = $this->billingShippingAddress( '', $this->order ); // done
911
912 $shortcode['[yaymail_billing_shipping_address_title]'] = $this->billingShippingAddressTitle( '', $this->order ); // done
913 $shortcode['[yaymail_billing_shipping_address_content]'] = $this->billingShippingAddressContent( '', $this->order ); // done
914 $shortcode['[yaymail_check_billing_shipping_address]'] = $this->checkBillingShippingAddress( '', $this->order );
915
916 if ( ! empty( parse_url( get_site_url() )['host'] ) ) {
917 $shortcode['[yaymail_domain]'] = parse_url( get_site_url() )['host'];
918 } else {
919 $shortcode['[yaymail_domain]'] = '';
920 }
921
922 $shortcode['[yaymail_user_account_url]'] = '<a style="color:' . $text_link_color . '; font-weight: normal; text-decoration: underline;" href="' . wc_get_page_permalink( 'myaccount' ) . '">' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '</a>';
923 $shortcode['[yaymail_user_account_url_string]'] = wc_get_page_permalink( 'myaccount' );
924
925 // ADDITIONAL ORDER META:
926 $order_metaArr = get_post_meta( $this->order_id );
927 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
928 foreach ( $order_metaArr as $k => $v ) {
929 $nameField = str_replace( ' ', '_', trim( $k ) );
930 $nameShorcode = '[yaymail_post_meta:' . $nameField . ']';
931
932 // when array $v has tow value ???
933 if ( is_array( $v ) && count( $v ) > 0 ) {
934 $shortcode[ $nameShorcode ] = trim( $v[0] );
935 } else {
936 $shortcode[ $nameShorcode ] = trim( $v );
937 }
938 }
939 }
940
941 /*
942 To get custom fields support Checkout Field Editor for WooCommerce */
943 // funtion wc_get_custom_checkout_fields of Plugin Checkout Field Editor ????
944 if ( ! empty( $order ) ) {
945 if ( function_exists( 'wc_get_custom_checkout_fields' ) ) {
946 $custom_fields = wc_get_custom_checkout_fields( $order );
947 if ( ! empty( $custom_fields ) ) {
948 foreach ( $custom_fields as $key => $custom_field ) {
949 $shortcode[ '[yaymail_' . $key . ']' ] = get_post_meta( $order->get_id(), $key, true );
950 }
951 }
952 }
953 }
954 if ( ! empty( $order ) ) {
955 foreach ( $order->get_meta_data() as $meta ) {
956 $nameField = str_replace( ' ', '_', trim( $meta->get_data()['key'] ) );
957 $nameShorcode = '[yaymail_order_meta:' . $nameField . ']';
958 if ( is_array( $meta->get_data()['value'] ) ) {
959 $checkNestedArray = false;
960 foreach ( $meta->get_data()['value'] as $value ) {
961 if ( is_object( $value ) || is_array( $value ) ) {
962 $checkNestedArray = true;
963 break;
964 }
965 }
966 if ( false == $checkNestedArray ) {
967 $shortcode[ $nameShorcode ] = implode( ', ', $meta->get_data()['value'] );
968 } else {
969 $shortcode[ $nameShorcode ] = '';
970 }
971 } else {
972 $shortcode[ $nameShorcode ] = $meta->get_data()['value'];
973 }
974 }
975 }
976
977 $this->order_data = $shortcode;
978 }
979
980 public function defaultSampleOrderData( $sent_to_admin = '' ) {
981 $current_user = wp_get_current_user();
982 $postID = CustomPostType::postIDByTemplate( $this->template );
983 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A';
984 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
985 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
986 $user_id = get_current_user_id();
987 $yaymail_settings = get_option( 'yaymail_settings' );
988 $yaymail_informations = array(
989 'post_id' => $postID,
990 'yaymail_elements' => get_post_meta( $postID, '_yaymail_elements', true ),
991 'template' => $this->template,
992 'general_settings' => array(
993 'tableWidth' => $yaymail_settings['container_width'],
994 'emailBackgroundColor' => get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : '#ECECEC',
995 'textLinkColor' => get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A',
996 ),
997 );
998
999 // Link Downloadable Product
1000 $shortcode['[yaymail_items_downloadable_title]'] = $this->itemsDownloadableTitle( '', $this->order, $sent_to_admin, '' ); // done
1001 $shortcode['[yaymail_items_downloadable_product]'] = $this->itemsDownloadableProduct( '', $this->order, $sent_to_admin, '' ); // done
1002
1003 // ORDER DETAILS
1004 $shortcode['[yaymail_items_border]'] = $this->itemsBorder( '', $this->order, $sent_to_admin ); // done
1005
1006 $shortcode['[yaymail_items_border_before]'] = $this->itemsBorderBefore( '', $this->order, $sent_to_admin ); // done
1007 $shortcode['[yaymail_items_border_after]'] = $this->itemsBorderAfter( '', $this->order, $sent_to_admin ); // done
1008 $shortcode['[yaymail_items_border_title]'] = $this->itemsBorderTitle( '', $this->order, $sent_to_admin ); // done
1009 $shortcode['[yaymail_items_border_content]'] = $this->itemsBorderContent( '', $this->order, $sent_to_admin ); // done
1010
1011 // WC HOOK
1012 $shortcode['[woocommerce_email_before_order_table]'] = $this->orderWoocommerceBeforeHook( array(), $sent_to_admin, 'sampleOrder' ); // not changed
1013 $shortcode['[woocommerce_email_after_order_table]'] = $this->orderWoocommerceAfterHook( array(), $sent_to_admin, 'sampleOrder' ); // not changed
1014
1015 // Yith-woocommerce-wishlist-premium
1016 // if ( function_exists( 'yith_wishlist_constructor' ) ) {
1017 // $shortcode['[yaymail_yith_wishlist_email_admin]'] = $this->yithWishlistEmailAdmin( '', $this->order, $sent_to_admin );
1018 // $shortcode['[yaymail_yith_wishlist_item_title]'] = $this->yithWishlistItemTitle( '', $this->order, $sent_to_admin );
1019 // $shortcode['[yaymail_yith_wishlist_item]'] = $this->yithWishlistItem( '', $this->order, $sent_to_admin );
1020 // $shortcode['[yaymail_yith_wishlist_additional_info]'] = $this->yithWishlistAdditionalInfo( '', $this->order, $sent_to_admin );
1021 // $shortcode['[yaymail_yith_wishlist_additional_data]'] = $this->yithWishlistAdditionalData( '', $this->order, $sent_to_admin );
1022 // $shortcode['[yaymail_yith_wishlist_customer_details]'] = $this->yithWishlistCustomerDetails( '', $this->order, $sent_to_admin );
1023 // }
1024
1025 // Define shortcode from plugin addon
1026 $shortcode = apply_filters( 'yaymail_do_shortcode', $shortcode, $yaymail_informations, '' );
1027
1028 $shortcode['[yaymail_items]'] = $this->orderItems( array(), $sent_to_admin, 'sampleOrder' );
1029 $shortcode['[yaymail_order_date]'] = gmdate( 'd-m-Y' );
1030 $shortcode['[yaymail_order_fee]'] = 0;
1031 $shortcode['[yaymail_order_id]'] = 1;
1032 $shortcode['[yaymail_order_link]'] = '<a href="" style="color:' . $text_link_color . ';">' . esc_html__( 'Order', 'yaymail' ) . '</a>';
1033 $shortcode['[yaymail_order_number]'] = '1';
1034 $shortcode['[yaymail_order_refund]'] = 0;
1035 $shortcode['[yaymail_order_sub_total]'] = '£18.00';
1036 $shortcode['[yaymail_order_total]'] = '£18.00';
1037
1038 // PAYMENTS
1039 $shortcode['[yaymail_order_payment_method]'] = 'Direct bank transfer';
1040 $shortcode['[yaymail_order_payment_url]'] = '<a href="">' . esc_html__( 'Payment page', 'yaymail' ) . '</a>';
1041 $shortcode['[yaymail_order_payment_url_string]'] = '';
1042 $shortcode['[yaymail_payment_method]'] = 'Check payments';
1043 $shortcode['[yaymail_transaction_id]'] = 1;
1044
1045 // SHIPPINGS
1046 $shortcode['[yaymail_order_shipping]'] = '333';
1047 $shortcode['[yaymail_shipping_address]'] = $shipping_address;
1048 $shortcode['[yaymail_shipping_address_1]'] = '755 E North Grove Rd';
1049 $shortcode['[yaymail_shipping_address_2]'] = '755 E North Grove Rd';
1050 $shortcode['[yaymail_shipping_city]'] = 'Mayville, Michigan';
1051 $shortcode['[yaymail_shipping_company]'] = 'YayCommerce';
1052 $shortcode['[yaymail_shipping_country]'] = '';
1053 $shortcode['[yaymail_shipping_first_name]'] = 'John';
1054 $shortcode['[yaymail_shipping_last_name]'] = 'Doe';
1055 $shortcode['[yaymail_shipping_method]'] = '';
1056 $shortcode['[yaymail_shipping_postcode]'] = '48744';
1057 $shortcode['[yaymail_shipping_state]'] = 'Random';
1058
1059 // BILLING
1060 $shortcode['[yaymail_billing_address]'] = $billing_address;
1061 $shortcode['[yaymail_billing_address_1]'] = '7400 Edwards Rd';
1062 $shortcode['[yaymail_billing_address_2]'] = '7400 Edwards Rd';
1063 $shortcode['[yaymail_billing_city]'] = 'Edwards Rd';
1064 $shortcode['[yaymail_billing_company]'] = 'YayCommerce';
1065 $shortcode['[yaymail_billing_country]'] = '';
1066 $shortcode['[yaymail_billing_email]'] = '[email protected]';
1067 $shortcode['[yaymail_billing_first_name]'] = 'John';
1068 $shortcode['[yaymail_billing_last_name]'] = 'Doe';
1069 $shortcode['[yaymail_billing_phone]'] = '(910) 529-1147';
1070 $shortcode['[yaymail_billing_postcode]'] = '48744';
1071 $shortcode['[yaymail_billing_state]'] = 'Random';
1072
1073 // RESET PASSWORD:
1074 $shortcode['[yaymail_password_reset_url]'] = '<a style="color:' . $text_link_color . ';" href="">' . esc_html__( 'Click here to reset your password', 'woocommerce' ) . '</a>';
1075 $shortcode['[yaymail_password_reset_url_string]'] = get_site_url() . '/my-account/lost-password/?login';
1076
1077 // NEW USERS:
1078 $shortcode['[yaymail_user_new_password]'] = 'G(UAM1(eIX#G';
1079 $shortcode['[yaymail_user_activation_link]'] = '';
1080
1081 // GENERALS
1082 $shortcode['[yaymail_customer_note]'] = 'note';
1083 $shortcode['[yaymail_customer_notes]'] = 'notes';
1084 $shortcode['[yaymail_customer_provided_note]'] = 'provided note';
1085 $shortcode['[yaymail_site_name]'] = get_bloginfo( 'name' );
1086 $shortcode['[yaymail_site_url]'] = '<a href="' . get_site_url() . '"> ' . get_site_url() . ' </a>';
1087 $shortcode['[yaymail_site_url_string]'] = get_site_url();
1088 $shortcode['[yaymail_user_email]'] = $current_user->data->user_email;
1089 $shortcode['[yaymail_user_id]'] = $user_id;
1090 $shortcode['[yaymail_customer_username]'] = $current_user->data->user_login;
1091 $shortcode['[yaymail_customer_name]'] = get_user_meta( $current_user->data->ID, 'first_name', true ) . ' ' . get_user_meta( $current_user->data->ID, 'last_name', true );
1092 $shortcode['[yaymail_view_order_url]'] = '';
1093 $shortcode['[yaymail_view_order_url_string]'] = '';
1094 $shortcode['[yaymail_billing_shipping_address]'] = $this->billingShippingAddress( '', $this->order ); // done
1095
1096 $shortcode['[yaymail_billing_shipping_address_title]'] = $this->billingShippingAddressTitle( '', $this->order ); // done
1097 $shortcode['[yaymail_billing_shipping_address_content]'] = $this->billingShippingAddressContent( '', $this->order ); // done
1098 $shortcode['[yaymail_check_billing_shipping_address]'] = $this->checkBillingShippingAddress( '', $this->order ); // done
1099
1100 $shortcode['[yaymail_domain]'] = parse_url( get_site_url() )['host'];
1101 $shortcode['[yaymail_user_account_url]'] = '<a style="color:' . $text_link_color . '; font-weight: normal; text-decoration: underline;" href="' . wc_get_page_permalink( 'myaccount' ) . '">' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '</a>';
1102 $shortcode['[yaymail_user_account_url_string]'] = wc_get_page_permalink( 'myaccount' );
1103
1104 // ADDITIONAL ORDER META:
1105 $order = CustomPostType::getListOrders();
1106 $order_metaArr = get_post_meta( isset( $order[0]['id'] ) ? $order[0]['id'] : '' );
1107 if ( is_array( $order_metaArr ) && count( $order_metaArr ) > 0 ) {
1108 foreach ( $order_metaArr as $k => $v ) {
1109 $nameField = str_replace( ' ', '_', trim( $k ) );
1110 $nameShorcode = '[yaymail_post_meta:' . $nameField . ']';
1111
1112 // when array $v has tow value ???
1113 if ( is_array( $v ) && count( $v ) > 0 ) {
1114 $shortcode[ $nameShorcode ] = trim( $v[0] );
1115 } else {
1116 $shortcode[ $nameShorcode ] = trim( $v );
1117 }
1118 }
1119 }
1120
1121 $this->order_data = $shortcode;
1122 }
1123
1124 public function ordetItemTables( $order, $default_args ) {
1125 $items = $order->get_items();
1126 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-items.php';
1127 $yaymail_settings = get_option( 'yaymail_settings' );
1128
1129 $show_product_image = isset( $yaymail_settings['product_image'] ) ? $yaymail_settings['product_image'] : 0;
1130 $show_product_sku = isset( $yaymail_settings['product_sku'] ) ? $yaymail_settings['product_sku'] : 0;
1131 $default_args['image_size'][0] = isset( $yaymail_settings['image_width'] ) ? $yaymail_settings['image_width'] : 32;
1132 $default_args['image_size'][1] = isset( $yaymail_settings['image_height'] ) ? $yaymail_settings['image_height'] : 32;
1133 $default_args['image_size'][2] = isset( $yaymail_settings['image_size'] ) ? $yaymail_settings['image_size'] : 'thumbnail';
1134
1135 $args = array(
1136 'order' => $order,
1137 'items' => $order->get_items(),
1138 'show_download_links' => $order->is_download_permitted() && ! $default_args['sent_to_admin'],
1139 'show_sku' => $show_product_sku,
1140 'show_purchase_note' => $order->is_paid() && ! $default_args['sent_to_admin'],
1141 'show_image' => $show_product_image,
1142 'image_size' => $default_args['image_size'],
1143 'plain_text' => $default_args['plain_text'],
1144 'sent_to_admin' => $default_args['sent_to_admin'],
1145 'order_item_table_border_color' => isset( $yaymail_settings['background_color_table_items'] ) ? $yaymail_settings['background_color_table_items'] : '#dddddd',
1146 );
1147 include $path;
1148 }
1149 public function itemsBorder( $atts, $order, $sent_to_admin = '' ) {
1150 if ( null === $order ) {
1151 ob_start();
1152 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details-border.php';
1153 include $path;
1154 $html = ob_get_contents();
1155 ob_end_clean();
1156 return $html;
1157 } else {
1158 ob_start();
1159 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border.php';
1160 include $path;
1161 $html = ob_get_contents();
1162 ob_end_clean();
1163 return $html;
1164 }
1165
1166 }
1167
1168 /* Link Downloadable Product - start */
1169 public function itemsDownloadableTitle( $atts, $order, $sent_to_admin = '', $items = array() ) {
1170 if ( null !== $order ) {
1171 $items = $order->get_items();
1172 $downloads = $order->get_downloadable_items();
1173 }
1174 ob_start();
1175 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-item-download-title.php';
1176 include $path;
1177 $html = ob_get_contents();
1178 ob_end_clean();
1179 return $html;
1180 }
1181 public function itemsDownloadableProduct( $atts, $order, $sent_to_admin = '', $items = array() ) {
1182 if ( null === $order ) {
1183 ob_start();
1184 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-item-download.php';
1185 include $path;
1186 $html = ob_get_contents();
1187 ob_end_clean();
1188 return $html;
1189 } else {
1190 $items = $order->get_items();
1191 ob_start();
1192 $downloads = $order->get_downloadable_items();
1193 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-item-download.php';
1194 include $path;
1195 $html = ob_get_contents();
1196 ob_end_clean();
1197 return $html;
1198 }
1199 }
1200
1201 /* Order items border - start */
1202 public function itemsBorderBefore( $atts, $order, $sent_to_admin = '' ) {
1203 if ( null === $order ) {
1204 return '';
1205 } else {
1206 ob_start();
1207 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-before.php';
1208 include $path;
1209 $html = ob_get_contents();
1210 ob_end_clean();
1211 return $html;
1212 }
1213 }
1214
1215 public function itemsBorderAfter( $atts, $order, $sent_to_admin = '' ) {
1216 if ( null === $order ) {
1217 return '';
1218 } else {
1219 ob_start();
1220 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-after.php';
1221 include $path;
1222 $html = ob_get_contents();
1223 ob_end_clean();
1224 return $html;
1225 }
1226 }
1227
1228 public function itemsBorderTitle( $atts, $order, $sent_to_admin = '' ) {
1229 if ( null === $order ) {
1230 ob_start();
1231 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details-border-title.php';
1232 include $path;
1233 $html = ob_get_contents();
1234 ob_end_clean();
1235 return $html;
1236 } else {
1237 ob_start();
1238 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-title.php';
1239 include $path;
1240 $html = ob_get_contents();
1241 ob_end_clean();
1242 return $html;
1243 }
1244 }
1245
1246 public function itemsBorderContent( $atts, $order, $sent_to_admin = '' ) {
1247 if ( null === $order ) {
1248 ob_start();
1249 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details-border-content.php';
1250 include $path;
1251 $html = ob_get_contents();
1252 ob_end_clean();
1253 return $html;
1254 } else {
1255 ob_start();
1256 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details-border-content.php';
1257 include $path;
1258 $html = ob_get_contents();
1259 ob_end_clean();
1260 return $html;
1261 }
1262 }
1263 /* Order items border - end */
1264
1265 public function billingShippingAddress( $atts, $order ) {
1266 $postID = CustomPostType::postIDByTemplate( $this->template );
1267 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A';
1268 if ( null !== $order ) {
1269 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
1270 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
1271 if ( $order->get_billing_phone() ) {
1272 $billing_address .= "<br/> <a href='tel:" . esc_html( $order->get_billing_phone() ) . "' style='color:" . $text_link_color . "; font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_phone() ) . '</a>';
1273 }
1274 if ( $order->get_billing_email() ) {
1275 $billing_address .= "<br/><a href='mailto:" . esc_html( $order->get_billing_email() ) . "' style='color:" . $text_link_color . ";font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_email() ) . '</a>';
1276 }
1277 } else {
1278 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1279 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1280 }
1281 ob_start();
1282 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-billing-shipping-address.php';
1283 $order = $this->order;
1284 include $path;
1285 $html = ob_get_contents();
1286 ob_end_clean();
1287 return $html;
1288
1289 }
1290
1291 /* Billing Shipping Address - start */
1292 public function billingShippingAddressTitle( $atts, $order ) {
1293 $postID = CustomPostType::postIDByTemplate( $this->template );
1294 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A';
1295 if ( null !== $order ) {
1296 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
1297 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
1298 } else {
1299 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1300 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1301 }
1302 ob_start();
1303 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-billing-shipping-address-title.php';
1304 $order = $this->order;
1305 include $path;
1306 $html = ob_get_contents();
1307 ob_end_clean();
1308 return $html;
1309 }
1310
1311 public function checkBillingShippingAddress( $atts, $order_id ) {
1312 $isShippingAddress = false;
1313 $isBillingAddress = false;
1314
1315 if ( ! empty( $billing_address ) ) {
1316 $isBillingAddress = true;
1317 }
1318 if ( ! empty( $shipping_address ) ) {
1319 $isShippingAddress = true;
1320 }
1321
1322 $args = array(
1323 'isShippingAddress' => $isShippingAddress,
1324 'isBillingAddress' => $isBillingAddress,
1325 );
1326
1327 return 'Checking_here';
1328 }
1329
1330 public function billingShippingAddressContent( $atts, $order ) {
1331 $postID = CustomPostType::postIDByTemplate( $this->template );
1332 $text_link_color = get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) ? get_post_meta( $postID, '_yaymail_email_textLinkColor_settings', true ) : '#96588A';
1333 if ( null !== $order ) {
1334 $shipping_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->shipping_address : $order->get_formatted_shipping_address();
1335 $billing_address = class_exists( 'Flexible_Checkout_Fields_Disaplay_Options' ) ? $this->billing_address : $order->get_formatted_billing_address();
1336 if ( $order->get_billing_phone() ) {
1337 $billing_address .= "<br/> <a href='tel:" . esc_html( $order->get_billing_phone() ) . "' style='color:" . $text_link_color . "; font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_phone() ) . '</a>';
1338 }
1339 if ( $order->get_billing_email() ) {
1340 $billing_address .= "<br/><a href='mailto:" . esc_html( $order->get_billing_email() ) . "' style='color:" . $text_link_color . ";font-weight: normal; text-decoration: underline;'>" . esc_html( $order->get_billing_email() ) . '</a>';
1341 }
1342 } else {
1343 $billing_address = "John Doe<br/>YayCommerce<br/>7400 Edwards Rd<br/>Edwards Rd<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1344 $shipping_address = "John Doe<br/>YayCommerce<br/>755 E North Grove Rd<br/>Mayville, Michigan<br/><a href='tel:+18587433828' style='color: " . $text_link_color . "; font-weight: normal; text-decoration: underline;'>(910) 529-1147</a><br/>";
1345 }
1346 ob_start();
1347 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-billing-shipping-address-content.php';
1348 $order = $this->order;
1349 include $path;
1350 $html = ob_get_contents();
1351 ob_end_clean();
1352 return $html;
1353 }
1354 /* Billing Shipping Address - end */
1355
1356 public function orderItems( $items, $sent_to_admin = '', $checkOrder = '' ) {
1357 if ( 'sampleOrder' === $checkOrder ) {
1358 ob_start();
1359 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sampleOrder/email-order-details.php';
1360 $order = $this->order;
1361 include $path;
1362 $html = ob_get_contents();
1363 ob_end_clean();
1364 return $html;
1365
1366 } else {
1367 ob_start();
1368 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/email-order-details.php';
1369 $order = $this->order;
1370 include $path;
1371 $html = ob_get_contents();
1372 ob_end_clean();
1373 return $html;
1374 }
1375
1376 }
1377 public function getOrderCustomerNotes( $customerNotes ) {
1378 ob_start();
1379 foreach ( $customerNotes as $customerNote ) {
1380 ?>
1381
1382 <?php echo wp_kses_post( $customerNote->comment_content ); ?>
1383
1384 <?php
1385 }
1386 $html = ob_get_contents();
1387 ob_end_clean();
1388 return $html;
1389 }
1390
1391 /* Woocommerce Hook - End */
1392 public function orderWoocommerceBeforeHook( $args, $sent_to_admin = '', $checkOrder = '' ) {
1393 if ( 'sampleOrder' === $checkOrder ) {
1394 return '[woocommerce_email_before_order_table]';
1395 } else {
1396 $order = $this->order;
1397 ob_start();
1398 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/wc-email-before.php';
1399 include $path;
1400 $html = ob_get_contents();
1401 ob_end_clean();
1402 return $html;
1403 }
1404 }
1405 public function orderWoocommerceAfterHook( $args, $sent_to_admin = '', $checkOrder = '' ) {
1406 if ( 'sampleOrder' === $checkOrder ) {
1407 return '[woocommerce_email_after_order_table]';
1408 } else {
1409 $order = $this->order;
1410 ob_start();
1411 $path = YAYMAIL_PLUGIN_PATH . 'views/templates/emails/wc-email-after.php';
1412 include $path;
1413 $html = ob_get_contents();
1414 ob_end_clean();
1415 return $html;
1416 }
1417 }
1418 }
1419