Added custom replacers to Preordercampaign Testmail

This commit is contained in:
Frank Schubert
2025-06-13 06:29:37 +02:00
parent e47ecb49cd
commit 0247aa677d
2 changed files with 11 additions and 3 deletions
+6 -1
View File
@@ -316,7 +316,7 @@ class Preorder extends mfBaseModel {
} }
public function runTriggerEmailAction($action) { public function runTriggerEmailAction($action, $custom_replacers = []) {
if(!array_key_exists("template", $action)) return false; if(!array_key_exists("template", $action)) return false;
if(!array_key_exists("from", $action)) return false; if(!array_key_exists("from", $action)) return false;
@@ -378,6 +378,11 @@ class Preorder extends mfBaseModel {
} }
} }
foreach($custom_replacers as $key => $value) {
if(!$key) continue;
$replacers[$key] = $value;
}
$subject = $mailtemplate->getVariableReplacedSubject($replacers); $subject = $mailtemplate->getVariableReplacedSubject($replacers);
$body = "<html><head></head><body>"; $body = "<html><head></head><body>";
$body .= $mailtemplate->renderBody($replacers); $body .= $mailtemplate->renderBody($replacers);
@@ -692,7 +692,7 @@ class PreordercampaignController extends mfBaseController {
return false; return false;
} }
$preorder = PreorderModel::getFirst(["preordercampaign_id" => $campaign_id]); $preorder = PreorderModel::getFirstActive(["preordercampaign_id" => $campaign_id]);
if(!$preorder) { if(!$preorder) {
return false; return false;
} }
@@ -709,7 +709,10 @@ class PreordercampaignController extends mfBaseController {
"data" => "preorder, adb_hausnummer, adb_wohneinheit" "data" => "preorder, adb_hausnummer, adb_wohneinheit"
]; ];
$preorder->runTriggerEmailAction($email_data); $preorder->runTriggerEmailAction($email_data, [
"RML_NEW_ORDER_PRICE_OPTION_EMBED" => "{{EMBED:tpl-rml-neue-bestellung-preistext-option2-preis}}",
"price_setup" => number_format(1500, 2, ",", "."),
]);
return ["message" => "Testemail sent"]; return ["message" => "Testemail sent"];
} }