1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
<?php ob_start(); if ( ! defined( 'ABSPATH' ) ) { exit; }
use YayMail\Page\Source\CustomPostType; use YayMail\Page\Source\UpdateElement; $flag_do_action = false; if ( isset( $args['yith_wc_email'] ) && isset( $args['yith_wc_email']->id ) && ! empty( $args['yith_wc_email']->id ) ) { // Get Email ID in yith-woocommerce-multi-vendor-premium $template = $args['yith_wc_email']->id; } else { $template = isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) ? $args['email']->id : false; if ( 'emails/customer-wholesale-register.php' == $template_name ) { $template = 'Dokan_Email_Wholesale_Register'; } if ( 'emails/admin-notify-approved.php' === $template_name ) { $template = 'admin_notify_approved'; } if ( 'customer_partially_refunded_order' === $template ) { $template = 'customer_refunded_order'; } if ( 'new-user-registration.php' == $template_name ) { $template = 'wp_crowdfunding_new_user'; } if ( 'campaign-accepted.php' == $template_name ) { $template = 'wp_crowdfunding_campaign_accept'; } if ( 'submit-campaign.php' == $template_name ) { $template = 'wp_crowdfunding_submit_campaign'; } if ( 'campaign-updated.php' == $template_name ) { $template = 'wp_crowdfunding_campaign_update_email'; } if ( 'new-backed.php' == $template_name ) { $template = 'wp_crowdfunding_new_backed'; } if ( 'campaign-target-reached.php' == $template_name ) { $template = 'wp_crowdfunding_target_reached_email'; } if ( 'withdraw-request.php' == $template_name ) { $template = 'wp_crowdfunding_withdraw_request'; } if ( class_exists( 'WC_Smart_Coupons' ) ) { if ( isset( $args['email'] ) && strpos( $default_path, plugin_dir_path( WC_SC_PLUGIN_FILE ) ) !== false ) { if ( 'email.php' === $template_name ) { $template = 'wc_sc_email_coupon'; } if ( 'combined-email.php' === $template_name ) { $template = 'wc_sc_combined_email_coupon'; } if ( 'acknowledgement-email.php' === $template_name ) { $template = 'wc_sc_acknowledgement_email'; } } } if ( 'emails/waitlist-mailout.php' == $template_name ) { $template = 'woocommerce_waitlist_mailout'; } if ( 'emails/waitlist-left.php' == $template_name ) { $template = 'woocommerce_waitlist_left_email'; } if ( 'emails/waitlist-joined.php' == $template_name ) { $template = 'woocommerce_waitlist_joined_email'; } if ( 'emails/waitlist-new-signup.php' == $template_name ) { $template = 'woocommerce_waitlist_signup_email'; } if ( 'emails/dokan-admin-new-booking.php' == $template_name ) { $template = 'Dokan_Email_Booking_New'; } if ( 'emails/dokan-customer-booking-cancelled.php' == $template_name ) { $template = 'Dokan_Email_Booking_Cancelled_NEW'; } } if ( isset( $args['email'] ) && isset( $args['email']->id ) && false !== strpos( get_class( $args['email'] ), 'ORDDD_Email_Delivery_Reminder' ) ) { $template .= '_customer'; }
if ( isset( $args['email'] ) && is_object( $args['email'] ) && 'WC_GZD_Email_Customer_Cancelled_Order' === get_class( $args['email'] ) && 'customer_failed_order' === $template ) { $template = 'customer_cancelled_order'; }
if ( isset( $check_YWCES ) && $check_YWCES ) { $template = 'YWCES_' . $email_template_type; }
if ( ( 'ywgc-email-send-gift-card' === $template || 'ywgc-email-delivered-gift-card' === $template ) && isset( $args['gift_card'] ) ) { if ( ! empty( $args['gift_card']->order_id ) ) { $args['order'] = wc_get_order( $args['gift_card']->order_id ); } }
$custom_shortcode = new YayMail\MailBuilder\Shortcodes( $template, '', false ); if ( CustomPostType::postIDByTemplate( $template ) ) { $postID = CustomPostType::postIDByTemplate( $template ); }
switch ( $template ) { case 'qwc_req_new_quote': case 'qwc_request_sent': case 'qwc_send_quote': $args['order'] = new WC_Order( $args['order']->order_id ); break; default: break; } if ( is_object( $args['email'] ) && isset( $args['email'] ) && 'wc_sc_email_coupon' != $template && 'wc_sc_combined_email_coupon' != $template && 'wc_sc_acknowledgement_email' != $template ) { $checkIsSumoTemp = strpos( get_class( $args['email'] ), 'SUMOSubscriptions' ); $checkIsQWCTemp = strpos( get_class( $args['email'] ), 'QWC' ); } else { $checkIsSumoTemp = false; $checkIsQWCTemp = false; } if ( ( false === $checkIsSumoTemp ) && ( false === $checkIsQWCTemp ) && isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) && isset( $args['order'] ) && $args['order']->get_id() ) { $flag_do_action = true; $custom_shortcode->setOrderId( $args['order']->get_id(), $args['sent_to_admin'], $args ); if ( isset( $args['sent_to_admin'] ) ) { if ( 1 === $args['order']->get_id() && false === $args['sent_to_admin'] ) { $custom_shortcode->shortCodesOrderSample(); } else { $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args ); } } else { $custom_shortcode->shortCodesOrderDefined(); } } elseif ( $template ) { $flag_do_action = true; if ( isset( $args['email'] ) && isset( $args['email']->id ) && ( 'customer_new_account' === $args['email']->id || 'customer_new_account_activation' === $args['email']->id || 'customer_reset_password' === $args['email']->id ) ) { $custom_shortcode->setOrderId( 0, $args['sent_to_admin'], $args ); $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args ); } else { $arrData = array( $custom_shortcode, $args, $template ); do_action_ref_array( 'yaymail_addon_defined_shorcode', array( &$arrData ) ); } }
if ( $flag_do_action ) {
// check plugin WBW Currency Switcher for WooCommerce active if(class_exists('\currencyWcu')) { $currencyWcu = \frameWcu::_()->getModule('currency'); remove_filter('woocommerce_order_get_total', array( $currencyWcu, 'getTotalCurrencyPrice'), 9999, 2); } $updateElement = new UpdateElement(); $yaymail_elements = get_post_meta( $postID, '_yaymail_elements', true ); $yaymail_elements = $updateElement->merge_new_props_to_elements( $yaymail_elements ); $yaymail_template = get_post_meta( $postID, '_yaymail_template', true ); $yaymail_settings = get_option( 'yaymail_settings' ); $emailBackgroundColor = get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : '#ECECEC'; $general_attrs = array( 'tableWidth' => str_replace( 'px', '', $yaymail_settings['container_width'] ) ); ?> <!DOCTYPE html > <html <?php language_attributes(); ?>> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"/> <meta name="x-apple-disable-message-reformatting" /> <style> h1{ font-family:inherit;text-shadow:unset;text-align:inherit;} h2,h3{ font-family:inherit;color:inherit;text-align:inherit;} .yaymail-inline-block {display: inline-block;}
</style> </head> <body style="background: <?php echo esc_attr( $emailBackgroundColor ); ?>" <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0"> <table style="background: <?php echo esc_attr( $emailBackgroundColor ); ?>" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" class="yaymail-customizer-email-template-container <?php echo esc_attr( 'yaymail-template-' . $yaymail_template ); ?>"> <?php foreach ( $yaymail_elements as $key => $element ) { ?> <tr><td> <?php $reg_pattern = '/\[([a-z0-9A-Z_]+)\]/'; if ( isset( $element['settingRow']['content'] ) ) { $content = $element['settingRow']['content']; $contentTitle = isset( $element['settingRow']['contentTitle'] ) ? $element['settingRow']['contentTitle'] : '';
// Add $atts for content if has shortcode preg_match_all( $reg_pattern, $content, $result ); if ( ! empty( $result[0] ) ) { foreach ( $result[0] as $key => $shortcode ) { $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : ''; $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : ''; $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : ''; $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : ''; $newshortcode = substr( $shortcode, 0, -1 ); $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']'; $content = str_replace( $shortcode, $newshortcode, $content ); } $element['settingRow']['content'] = $content; } // Add $atts for contentTitle if has shortcode if ( $contentTitle ) { preg_match_all( $reg_pattern, $contentTitle, $result ); if ( ! empty( $result[0] ) ) { foreach ( $result[0] as $key => $shortcode ) { $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : ''; $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : ''; $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : ''; $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : ''; $newshortcode = substr( $shortcode, 0, -1 ); $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']'; $contentTitle = str_replace( $shortcode, $newshortcode, $contentTitle ); } $element['settingRow']['contentTitle'] = $contentTitle; } }
// Add $atts for content of shipment tracking if has shortcode if ( '[yaymail_order_meta:_wc_shipment_tracking_items]' === $content ) { $shortcode = $content; $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : ''; $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : ''; $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : ''; $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : ''; $newshortcode = substr( $shortcode, 0, -1 ); $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']'; $content = str_replace( $shortcode, $newshortcode, $content ); $element['settingRow']['content'] = $content; } } if ( has_filter( 'yaymail_addon_for_conditional_logic' ) && isset( $element['settingRow']['arrConditionLogic'] ) ) { if ( ! empty( $element['settingRow']['arrConditionLogic'] ) ) { $conditional_Logic = apply_filters( 'yaymail_addon_for_conditional_logic', false, $args, $element['settingRow'] ); if ( $conditional_Logic ) { do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false ); } } else { if ( 'OneColumn' === $element['type'] || 'TwoColumns' === $element['type'] || 'ThreeColumns' === $element['type'] || 'FourColumns' === $element['type'] ) { for ( $column = 1; $column <= 4; $column++ ) { if ( isset( $element['settingRow'][ 'column' . $column ] ) ) { foreach ( $element['settingRow'][ 'column' . $column ] as $column_key => $column_element ) { if ( isset( $column_element['settingRow']['arrConditionLogic'] ) && ! empty( $column_element['settingRow']['arrConditionLogic'] ) ) { $conditional_Logic = apply_filters( 'yaymail_addon_for_conditional_logic', false, $args, $column_element['settingRow'] ); if ( ! $conditional_Logic ) { unset( $element['settingRow'][ 'column' . $column ][ $column_key ] ); } } } } } } do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false ); } } else { do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false ); }
?> </td></tr> <?php } ?> </table> </body> </html> <?php }
|