| 1 |
<?php |
| 2 |
|
| 3 |
namespace YayMail\MailBuilder; |
| 4 |
|
| 5 |
use YayMail\Page\Source\CustomPostType; |
| 6 |
use YayMail\MailBuilder\PIPTemplate; |
| 7 |
|
| 8 |
defined( 'ABSPATH' ) || exit; |
| 9 |
/** |
| 10 |
* Settings Page |
| 11 |
*/ |
| 12 |
class WooTemplate { |
| 13 |
|
| 14 |
|
| 15 |
protected static $instance = null; |
| 16 |
private $templateAccount; |
| 17 |
private $templateSubscription; |
| 18 |
private $automatewoo_info = null; |
| 19 |
private $automatewoo_referrals_email_content = null; |
| 20 |
private $trackShipArgs = null; |
| 21 |
private $FUE_Sending_Email_Variables = null; |
| 22 |
public static function getInstance() { |
| 23 |
if ( null == self::$instance ) { |
| 24 |
self::$instance = new self(); |
| 25 |
self::$instance->doHooks(); |
| 26 |
} |
| 27 |
|
| 28 |
return self::$instance; |
| 29 |
} |
| 30 |
|
| 31 |
private function doHooks() { |
| 32 |
$this->templateAccount = array( 'customer_new_account', 'customer_new_account_activation', 'customer_reset_password' ); |
| 33 |
$this->templateGermanizedForWC = array( 'sab_simple_invoice', 'sab_cancellation_invoice', 'sab_packing_slip', 'sab_document_admin', 'sab_document' ); |
| 34 |
add_filter( 'storeabill_get_template', array( $this, 'storeabill_get_template' ), 100, 5 ); |
| 35 |
add_filter( 'wc_get_template', array( $this, 'getTemplateMail' ), 100, 5 ); |
| 36 |
|
| 37 |
if ( has_filter( 'YaymailCreateFollowUpTemplates' ) ) { |
| 38 |
add_action( 'fue_before_variable_replacements', array( $this, 'register_variable_replacements' ), 100, 4 ); |
| 39 |
add_filter( 'fue_before_sending_email', array( $this, 'getFollowUpTemplates' ), 100, 3 ); |
| 40 |
} |
| 41 |
|
| 42 |
if ( class_exists( 'WC_PIP_Loader' ) && class_exists( 'YayMailWooPrintInvoices\\templateDefault\\DefaultInvoice' ) && class_exists( 'YayMailWooPrintInvoices\\templateDefault\\DefaultPickList' ) ) { |
| 43 |
PIPTemplate::handle_trigger(); |
| 44 |
} |
| 45 |
add_filter( 'retrieve_password_message', array( $this, 'admin_reset_password' ), 100, 4 ); |
| 46 |
add_action( 'automatewoo_before_action_run', array( $this, 'automatewoo_before_action_run' ), 10 ); |
| 47 |
add_filter( 'automatewoo/referrals/invite_email/mailer', array( $this, 'automatewoo_invite_email' ), 100, 2 ); |
| 48 |
|
| 49 |
if ( class_exists( 'WCFM' ) ) { |
| 50 |
$WCFMWooFM_Template = CustomPostType::postIDByTemplate( 'WCFMWooFM_Template' ); |
| 51 |
if ( get_post_meta( $WCFMWooFM_Template, '_yaymail_status', true ) ) { |
| 52 |
global $WCFM; |
| 53 |
remove_action( 'wcfm_email_content_wrapper', array( $WCFM, 'wcfm_email_content_wrapper' ), 10 ); |
| 54 |
add_filter( 'wcfm_email_content_wrapper', array( &$this, 'wcfm_email_content_wrapper' ), 1, 2 ); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
add_filter( 'wpml_translate_single_string', array( $this, 'yaymail_ywces_new_template' ), 1, 3 ); |
| 59 |
// change german market template dir |
| 60 |
$this->yaymail_get_german_market_templates(); |
| 61 |
|
| 62 |
if ( class_exists( 'CARTFLOWS_CA_Loader' ) && function_exists( 'YayMailAddonWcCartAbandonmentRecovery\\init' ) ) { |
| 63 |
add_filter( 'woo_ca_recovery_email_data', array( $this, 'yaymail_addon_ca_recovery_send_mail' ), 10, 1 ); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
public function yaymail_addon_ca_recovery_send_mail( $email_data ) { |
| 68 |
$ca_recovery_template_id = $email_data->email_template_id; |
| 69 |
|
| 70 |
if ( empty( $ca_recovery_template_id ) ) { |
| 71 |
return $email_data; |
| 72 |
} |
| 73 |
$yaymail_template_id = 'YaymailWcCaRecovery_' . $ca_recovery_template_id; |
| 74 |
|
| 75 |
if ( ! empty( $yaymail_template_id ) ) { |
| 76 |
$postID = null; |
| 77 |
$postID = CustomPostType::postIDByTemplate( $yaymail_template_id ); |
| 78 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 79 |
} |
| 80 |
|
| 81 |
if ( $template_status && ! empty( $postID ) ) { |
| 82 |
$active_template = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' : false; |
| 83 |
|
| 84 |
$args['email'] = $email_data; |
| 85 |
$template = $yaymail_template_id; |
| 86 |
if ( $active_template ) { |
| 87 |
ob_start(); |
| 88 |
include $active_template; |
| 89 |
$template_body = ob_get_contents(); |
| 90 |
ob_end_clean(); |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
if ( ! empty( $template_body ) ) { |
| 95 |
$email_data->email_body = $template_body; |
| 96 |
} |
| 97 |
|
| 98 |
return $email_data; |
| 99 |
} |
| 100 |
|
| 101 |
public function yaymail_ywces_new_template( $mail_body_content, $admin_mail_body_text, $mail_body_text ) { |
| 102 |
if ( class_exists( 'YayMailYITHWooCouponEmailSystem\templateDefault\DefaultCouponEmailSystem' ) && class_exists( 'YITH_WC_Coupon_Email_System' ) && false !== strpos( $mail_body_text, 'ywces_mailbody_' ) ) { |
| 103 |
$mail_body_text_explode = explode( 'ywces_mailbody_', $mail_body_text ); |
| 104 |
$email_template_type = $mail_body_text_explode[1]; |
| 105 |
$template = 'YWCES_' . $email_template_type; |
| 106 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 107 |
if ( $postID ) { |
| 108 |
if ( get_post_meta( $postID, '_yaymail_status', true ) && ! empty( get_post_meta( $postID, '_yaymail_elements', true ) ) ) { |
| 109 |
$check_YWCES = true; |
| 110 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' : false; |
| 111 |
ob_start(); |
| 112 |
include $templateActive; |
| 113 |
$template_body = ob_get_contents(); |
| 114 |
// Replace newline (\n) in a string to YAYMAIL_YWCES_YAY |
| 115 |
$template_body = str_replace( "\n", 'YAYMAIL_YWCES_YAY', $template_body ); |
| 116 |
ob_end_clean(); |
| 117 |
return $template_body; |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
return $mail_body_content; |
| 123 |
} |
| 124 |
|
| 125 |
public function yaymail_get_german_market_templates() { |
| 126 |
if ( class_exists( 'Woocommerce_German_Market' ) ) { |
| 127 |
add_filter( |
| 128 |
'wgm_locate_template', |
| 129 |
function( $template, $template_name, $template_path ) { |
| 130 |
if ( 'emails/customer-confirm-order.php' === $template_name ) { |
| 131 |
$postID = CustomPostType::postIDByTemplate( 'wgm_confirm_order_email' ); |
| 132 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 133 |
if ( $template_status ) { |
| 134 |
return YAYMAIL_PLUGIN_PATH . 'views/templates/emails/customer-confirm-order.php'; |
| 135 |
} |
| 136 |
} elseif ( 'double-opt-in-customer-registration.php' === $template_name ) { |
| 137 |
$postID = CustomPostType::postIDByTemplate( 'wgm_double_opt_in_customer_registration' ); |
| 138 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 139 |
if ( $template_status ) { |
| 140 |
return YAYMAIL_PLUGIN_PATH . 'views/templates/emails/double-opt-in-customer-registration.php'; |
| 141 |
} |
| 142 |
} elseif ( 'emails/sepa-mandate.php' === $template_name ) { |
| 143 |
$postID = CustomPostType::postIDByTemplate( 'wgm_sepa' ); |
| 144 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 145 |
if ( $template_status ) { |
| 146 |
return YAYMAIL_PLUGIN_PATH . 'views/templates/emails/sepa.php'; |
| 147 |
} |
| 148 |
} |
| 149 |
return $template; |
| 150 |
}, |
| 151 |
100, |
| 152 |
3 |
| 153 |
); |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
public function wcfm_email_content_wrapper( $content_body, $email_heading ) { |
| 158 |
$template = 'WCFMWooFM_Template'; |
| 159 |
$postID = CustomPostType::postIDByTemplate( 'WCFMWooFM_Template' ); |
| 160 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' : false; |
| 161 |
$args = array( |
| 162 |
'order' => null, |
| 163 |
'content_body' => $content_body, |
| 164 |
'email_heading' => $email_heading, |
| 165 |
); |
| 166 |
ob_start(); |
| 167 |
include $templateActive; |
| 168 |
$template_body = ob_get_contents(); |
| 169 |
ob_end_clean(); |
| 170 |
return $template_body; |
| 171 |
} |
| 172 |
|
| 173 |
public function automatewoo_invite_email( $mailer, $invite_email ) { |
| 174 |
if ( defined( 'YAYMAIL_ADDON_AUTOMATEWOO' ) && ! empty( YAYMAIL_ADDON_AUTOMATEWOO ) ) { |
| 175 |
$template = 'AutomateWoo_Referrals_Email'; |
| 176 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 177 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 178 |
if ( $template_status ) { |
| 179 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' : false; |
| 180 |
ob_start(); |
| 181 |
include $templateActive; |
| 182 |
$template_body = ob_get_contents(); |
| 183 |
ob_end_clean(); |
| 184 |
if ( '' !== $template_body ) { |
| 185 |
$template_body = $invite_email->replace_variables( $template_body ); |
| 186 |
$this->automatewoo_referrals_email_content = $template_body; |
| 187 |
} |
| 188 |
add_filter( |
| 189 |
'woocommerce_mail_content', |
| 190 |
function( $email_content ) { |
| 191 |
return $this->automatewoo_referrals_email_content; |
| 192 |
}, |
| 193 |
100, |
| 194 |
1 |
| 195 |
); |
| 196 |
} |
| 197 |
} |
| 198 |
return $mailer; |
| 199 |
} |
| 200 |
public function automatewoo_before_action_run( $action ) { |
| 201 |
if ( defined( 'YAYMAIL_ADDON_AUTOMATEWOO' ) && ! empty( YAYMAIL_ADDON_AUTOMATEWOO ) ) { |
| 202 |
$this->automatewoo_info = $action; |
| 203 |
$template = 'AutomateWoo_' . $action->workflow->get_id(); |
| 204 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 205 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 206 |
if ( $template_status ) { |
| 207 |
add_filter( |
| 208 |
'woocommerce_mail_content', |
| 209 |
function( $html ) { |
| 210 |
$workflow = $this->automatewoo_info->workflow; |
| 211 |
$template = 'AutomateWoo_' . $workflow->get_id(); |
| 212 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 213 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' : false; |
| 214 |
$raw_data = $workflow->data_layer()->get_raw_data(); |
| 215 |
$args = array( |
| 216 |
'order' => isset( $raw_data['order'] ) ? $raw_data['order'] : null, |
| 217 |
'subscription' => isset( $raw_data['subscription'] ) ? $raw_data['subscription'] : null, |
| 218 |
'email' => '', |
| 219 |
'workflow' => $workflow, |
| 220 |
); |
| 221 |
|
| 222 |
ob_start(); |
| 223 |
include $templateActive; |
| 224 |
$template_body = ob_get_contents(); |
| 225 |
ob_end_clean(); |
| 226 |
if ( '' !== $template_body ) { |
| 227 |
$template_body = $workflow->variable_processor()->process_field( $template_body, true ); |
| 228 |
$email = new \AutomateWoo\Workflow_Email( $workflow, '', '', $template_body ); |
| 229 |
$get_mailer = $email->get_mailer(); |
| 230 |
if ( $workflow->is_tracking_enabled() ) { |
| 231 |
$template_body = $get_mailer->inject_tracking_pixel( $template_body ); |
| 232 |
$template_body = $get_mailer->replace_urls_in_content( $template_body ); |
| 233 |
} |
| 234 |
$template_body = $get_mailer->style_inline( $template_body ); |
| 235 |
return $template_body; |
| 236 |
} |
| 237 |
return $html; |
| 238 |
}, |
| 239 |
10 |
| 240 |
); |
| 241 |
} |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
public function storeabill_get_template( $located, $template_name, $args, $template_path, $default_path ) { |
| 246 |
$this_template = false; |
| 247 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' : false; |
| 248 |
$template = isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) ? $args['email']->id : false; |
| 249 |
|
| 250 |
if ( $template ) { |
| 251 |
if ( CustomPostType::postIDByTemplate( $template ) ) { |
| 252 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 253 |
if ( get_post_meta( $postID, '_yaymail_status', true ) && ! empty( get_post_meta( $postID, '_yaymail_elements', true ) ) ) { |
| 254 |
if ( in_array( $template, $this->templateGermanizedForWC ) ) { // template mail with account |
| 255 |
$this_template = $templateActive; |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
} |
| 260 |
$this_template = $this_template ? $this_template : $located; |
| 261 |
return $this_template; |
| 262 |
} |
| 263 |
|
| 264 |
private function __construct() {} |
| 265 |
// define the woocommerce_new_order callback |
| 266 |
|
| 267 |
public function admin_reset_password( $message, $key, $user_login, $user_data ) { |
| 268 |
$this_template = false; |
| 269 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' : false; |
| 270 |
$template = 'customer_reset_password'; |
| 271 |
$email = array( |
| 272 |
'id' => 'customer_reset_password', |
| 273 |
'user_login' => $user_login, |
| 274 |
'user_id' => $user_data->ID, |
| 275 |
'user_email' => $user_data->data->user_email, |
| 276 |
'user_data' => $user_data, |
| 277 |
'key' => $key, |
| 278 |
); |
| 279 |
$args = array( |
| 280 |
'email' => (object) $email, |
| 281 |
'sent_to_admin' => false, |
| 282 |
'reset_key' => $key, |
| 283 |
); |
| 284 |
$holder_order = isset( $args['order'] ) ? $args['order'] : null; |
| 285 |
if ( CustomPostType::postIDByTemplate( $template, $holder_order ) ) { |
| 286 |
$postID = CustomPostType::postIDByTemplate( $template, $holder_order ); |
| 287 |
if ( get_post_meta( $postID, '_yaymail_status', true ) && ! empty( get_post_meta( $postID, '_yaymail_elements', true ) ) ) { |
| 288 |
if ( isset( $args['order'] ) || in_array( $template, $this->templateAccount ) ) { // template mail with order |
| 289 |
$this_template = $templateActive; |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
$template_path = ''; |
| 294 |
$template_name = 'emails/customer-reset-password.php'; |
| 295 |
if ( false !== $this_template ) { |
| 296 |
ob_start(); |
| 297 |
include $this_template; |
| 298 |
$message = ob_get_contents(); |
| 299 |
ob_end_clean(); |
| 300 |
$site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
| 301 |
// translators: none. |
| 302 |
$title = sprintf( __( '[%s] Password Reset', 'yaymail' ), $site_name ); |
| 303 |
wc_mail( $email['user_email'], $title, $message ); |
| 304 |
$message = false; |
| 305 |
} |
| 306 |
return $message; |
| 307 |
} |
| 308 |
|
| 309 |
// support addon TrackShip for WooCommerce |
| 310 |
public function woocommerce_mail_content( $html ) { |
| 311 |
$trackshipArgs = $this->trackShipArgs; |
| 312 |
$template = 'trackship_' . $trackshipArgs['new_status']; |
| 313 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 314 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' : false; |
| 315 |
$args = array( |
| 316 |
'order_id' => isset( $trackshipArgs['order_id'] ) ? $trackshipArgs['order_id'] : '0', |
| 317 |
'show_shipment_status' => isset( $trackshipArgs['show_shipment_status'] ) ? $trackshipArgs['show_shipment_status'] : false, |
| 318 |
'new_status' => isset( $trackshipArgs['new_status'] ) ? $trackshipArgs['new_status'] : '', |
| 319 |
'tracking_items' => isset( $trackshipArgs['tracking_items'] ) ? $trackshipArgs['tracking_items'] : array(), |
| 320 |
'shipment_status' => isset( $trackshipArgs['shipment_status'] ) ? $trackshipArgs['shipment_status'] : array(), |
| 321 |
); |
| 322 |
|
| 323 |
ob_start(); |
| 324 |
include $templateActive; |
| 325 |
$template_body = ob_get_contents(); |
| 326 |
ob_end_clean(); |
| 327 |
if ( '' !== $template_body ) { |
| 328 |
return $template_body; |
| 329 |
} |
| 330 |
return $html; |
| 331 |
|
| 332 |
} |
| 333 |
|
| 334 |
public function getTemplateMail( $located, $template_name, $args, $template_path, $default_path ) { |
| 335 |
// support addon TrackShip for WooCommerce |
| 336 |
if ( 'emails/tracking-info.php' == $template_name ) { |
| 337 |
$this->trackShipArgs = $args; |
| 338 |
if ( isset( $args['new_status'] ) ) { |
| 339 |
$template = 'trackship_' . $args['new_status']; |
| 340 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 341 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 342 |
if ( $template_status ) { |
| 343 |
add_filter( 'woocommerce_mail_content', array( $this, 'woocommerce_mail_content' ), 100 ); |
| 344 |
} |
| 345 |
} |
| 346 |
} |
| 347 |
$this_template = false; |
| 348 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-mail-template.php' : false; |
| 349 |
if ( isset( $args['yith_wc_email'] ) && isset( $args['yith_wc_email']->id ) && ! empty( $args['yith_wc_email']->id ) ) { |
| 350 |
// Get Email ID in yith-woocommerce-multi-vendor-premium |
| 351 |
$template = $args['yith_wc_email']->id; |
| 352 |
} else { |
| 353 |
$template = isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) ? $args['email']->id : false; |
| 354 |
if ( 'dokan-wholesale/' == $template_path ) { |
| 355 |
$template = 'Dokan_Email_Wholesale_Register'; |
| 356 |
} |
| 357 |
if ( 'new-user-registration.php' == $template_name ) { |
| 358 |
$template = 'wp_crowdfunding_new_user'; |
| 359 |
} |
| 360 |
if ( 'campaign-accepted.php' == $template_name ) { |
| 361 |
$template = 'wp_crowdfunding_campaign_accept'; |
| 362 |
} |
| 363 |
if ( 'submit-campaign.php' == $template_name ) { |
| 364 |
$template = 'wp_crowdfunding_submit_campaign'; |
| 365 |
} |
| 366 |
if ( 'campaign-updated.php' == $template_name ) { |
| 367 |
$template = 'wp_crowdfunding_campaign_update_email'; |
| 368 |
} |
| 369 |
if ( 'new-backed.php' == $template_name ) { |
| 370 |
$template = 'wp_crowdfunding_new_backed'; |
| 371 |
} |
| 372 |
if ( 'campaign-target-reached.php' == $template_name ) { |
| 373 |
$template = 'wp_crowdfunding_target_reached_email'; |
| 374 |
} |
| 375 |
if ( 'withdraw-request.php' == $template_name ) { |
| 376 |
$template = 'wp_crowdfunding_withdraw_request'; |
| 377 |
} |
| 378 |
if ( class_exists( 'WC_Smart_Coupons' ) ) { |
| 379 |
if ( isset( $args['email'] ) && strpos( $located, plugin_dir_path( WC_SC_PLUGIN_FILE ) ) !== false ) { |
| 380 |
$templateName = str_replace( plugin_dir_path( WC_SC_PLUGIN_FILE ) . 'templates/', '', $located ); |
| 381 |
if ( 'email.php' == $templateName ) { |
| 382 |
$template = 'wc_sc_email_coupon'; |
| 383 |
$args['id'] = 'wc_sc_email_coupon'; |
| 384 |
} |
| 385 |
if ( 'combined-email.php' == $templateName ) { |
| 386 |
$template = 'wc_sc_combined_email_coupon'; |
| 387 |
$args['id'] = 'wc_sc_combined_email_coupon'; |
| 388 |
} |
| 389 |
if ( 'acknowledgement-email.php' == $templateName ) { |
| 390 |
$template = 'wc_sc_acknowledgement_email'; |
| 391 |
$args['id'] = 'wc_sc_acknowledgement_email'; |
| 392 |
} |
| 393 |
} |
| 394 |
} |
| 395 |
if ( 'emails/waitlist-mailout.php' == $template_name ) { |
| 396 |
$template = 'woocommerce_waitlist_mailout'; |
| 397 |
} |
| 398 |
if ( 'emails/waitlist-left.php' == $template_name ) { |
| 399 |
$template = 'woocommerce_waitlist_left_email'; |
| 400 |
} |
| 401 |
if ( 'emails/waitlist-joined.php' == $template_name ) { |
| 402 |
$template = 'woocommerce_waitlist_joined_email'; |
| 403 |
} |
| 404 |
if ( 'emails/waitlist-new-signup.php' == $template_name ) { |
| 405 |
$template = 'woocommerce_waitlist_signup_email'; |
| 406 |
} |
| 407 |
|
| 408 |
if ( 'emails/dokan-admin-new-booking.php' == $template_name ) { |
| 409 |
$template = 'Dokan_Email_Booking_New'; |
| 410 |
} |
| 411 |
if ( 'emails/dokan-customer-booking-cancelled.php' == $template_name ) { |
| 412 |
$template = 'Dokan_Email_Booking_Cancelled_NEW'; |
| 413 |
} |
| 414 |
} |
| 415 |
|
| 416 |
if ( isset( $args['email'] ) && isset( $args['email']->id ) && false !== strpos( get_class( $args['email'] ), 'ORDDD_Email_Delivery_Reminder' ) ) { |
| 417 |
$template .= '_customer'; |
| 418 |
} |
| 419 |
|
| 420 |
if ( isset( $args['email'] ) && is_object( $args['email'] ) && 'WC_GZD_Email_Customer_Cancelled_Order' === get_class( $args['email'] ) && 'customer_failed_order' === $template ) { |
| 421 |
$template = 'customer_cancelled_order'; |
| 422 |
} |
| 423 |
|
| 424 |
// can't load tempalte email-delivery-date.php because it will has error when check out, with plugin WooCommerce Order Delivery |
| 425 |
if ( $template && 'emails/email-delivery-date.php' != $template_name && 'emails/email-order-details.php' != $template_name ) { |
| 426 |
|
| 427 |
// Yith Stripe |
| 428 |
|
| 429 |
if ( 'emails/expiring-card-email.php' === $template_name ) { |
| 430 |
$template = 'expiring_card'; |
| 431 |
} |
| 432 |
if ( 'emails/renew-needs-action-email.php' === $template_name ) { |
| 433 |
$template = 'renew_needs_action'; |
| 434 |
} |
| 435 |
|
| 436 |
if ( 'emails/admin-notify-approved.php' === $template_name ) { |
| 437 |
$template = 'admin_notify_approved'; |
| 438 |
} |
| 439 |
if ( 'customer_partially_refunded_order' === $template ) { |
| 440 |
$template = 'customer_refunded_order'; |
| 441 |
} |
| 442 |
if ( CustomPostType::postIDByTemplate( $template ) ) { |
| 443 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 444 |
if ( get_post_meta( $postID, '_yaymail_status', true ) && ! empty( get_post_meta( $postID, '_yaymail_elements', true ) ) ) { |
| 445 |
if ( isset( $args['order'] ) || in_array( $template, $this->templateAccount ) ) { // template mail with order |
| 446 |
$this_template = $templateActive; |
| 447 |
} else { |
| 448 |
$checkHasTempalte = apply_filters( 'yaymail_addon_defined_template', false, $template ); |
| 449 |
if ( $checkHasTempalte ) { // template mail with account |
| 450 |
$this_template = $templateActive; |
| 451 |
} |
| 452 |
} |
| 453 |
} |
| 454 |
} |
| 455 |
} |
| 456 |
$this_template = $this_template ? $this_template : $located; |
| 457 |
return $this_template; |
| 458 |
} |
| 459 |
|
| 460 |
public function register_variable_replacements( $var, $email_data, $email, $queue_item ) { |
| 461 |
$this->FUE_Sending_Email_Variables = $var; |
| 462 |
} |
| 463 |
|
| 464 |
public function getFollowUpTemplates( $email_data, $email, $queue_item ) { |
| 465 |
if ( has_filter( 'yaymail_follow_up_shortcode' ) ) { |
| 466 |
$templateActive = file_exists( YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' ) ? YAYMAIL_PLUGIN_PATH . 'views/templates/single-follow-up-mail-template.php' : false; |
| 467 |
$template = 'follow_up_email_' . $email->id; |
| 468 |
$postID = CustomPostType::postIDByTemplate( $template ); |
| 469 |
$template_status = get_post_meta( $postID, '_yaymail_status', true ); |
| 470 |
$args = array( |
| 471 |
'email_data' => $email_data, |
| 472 |
'email' => $email, |
| 473 |
'queue_item' => $queue_item, |
| 474 |
); |
| 475 |
if ( $template_status ) { |
| 476 |
ob_start(); |
| 477 |
include $templateActive; |
| 478 |
$template_body = ob_get_contents(); |
| 479 |
$FUE_Sending_Email_Variables = $this->FUE_Sending_Email_Variables; |
| 480 |
$template_body = $FUE_Sending_Email_Variables->apply_replacements( $template_body ); |
| 481 |
ob_end_clean(); |
| 482 |
$email_data['message'] = $template_body; |
| 483 |
} |
| 484 |
} |
| 485 |
return $email_data; |
| 486 |
} |
| 487 |
} |
| 488 |
|