Add additional text to email template container





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















This is my system.xml file:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="afteremail" translate="label" sortOrder="10">
<label>Label</label>
</tab>
<section id="afteremail" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>After Email</label>
<tab>afteremail</tab>
<resource>Module_Vendor::afteremail_config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Display Text</label>
<comment>This text will display on the all transactional emails.</comment>
</field>
</group>
</section>
</system>
</config>


And config.xml:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<afteremail>
<general>
<display_text>Hello World</display_text>
</general>
</afteremail>
</default>
</config>


Helper Data.php



<?php

namespace VendorModuleHelper;

use MagentoFrameworkAppHelperAbstractHelper;
use MagentoStoreModelScopeInterface;

class Data extends AbstractHelper
{

const XML_PATH_AFTEREMAIL = 'afteremail/';

public function getConfigValue($field, $storeId = null)
{
return $this->scopeConfig->getValue(
$field, ScopeInterface::SCOPE_STORE, $storeId
);
}

public function getGeneralConfig($code, $storeId = null)
{

return $this->getConfigValue(self::XML_PATH_AFTEREMAIL .'general/'. $code, $storeId);
}

}


As well as Plugin.php



<?php

namespace VendorModulePlugin;

use MagentoEmailControllerAdminhtmlEmailTemplateDefaultTemplate;

class AddText
{
/**
* @var MagentoFrameworkSerializeSerializerJson
*/
protected $serializer;

protected $helperData;

public function __construct(
MagentoFrameworkSerializeSerializerJson $serializer,
VendorModuleHelperData $helperData
) {
$this->serializer = $serializer;
$this->helperData = $helperData;
}

/**
* @param DefaultTemplate $template
* @param $result
*/
public function afterExecute(DefaultTemplate $template, $result)
{
$displayText = $this->helperData->getGeneralConfig('display_text');
/** @var MagentoFrameworkAppResponseHttp $response */
$response = $template->getResponse();
$body = $this->serializer->unserialize($response->getBody());

$body['template_text'] .= PHP_EOL . PHP_EOL . $displayText;

$response->representJson(
$this->serializer->serialize($body)
);
}
}


For now, additional text displays out of email container.
I want to achieve that it displays in the container.
Any suggestions on how to do that will be highly appreciated!
Thanks!










share|improve this question























  • You can try another way to do that. Create a custom variable from Magento Admin panel, insert your text on that custom variable. then create a new footer template and insert your custom variable on the new footer email template. Please see this URL bsscommerce.com/blog/customize--magento-2-footer-template

    – Pritam Info 24
    10 hours ago











  • This method partly solves my task, but the idea is to edit text in the config tab. I suppose there is no option to update variable text from config tab.

    – Rufus
    10 hours ago


















0















This is my system.xml file:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="afteremail" translate="label" sortOrder="10">
<label>Label</label>
</tab>
<section id="afteremail" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>After Email</label>
<tab>afteremail</tab>
<resource>Module_Vendor::afteremail_config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Display Text</label>
<comment>This text will display on the all transactional emails.</comment>
</field>
</group>
</section>
</system>
</config>


And config.xml:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<afteremail>
<general>
<display_text>Hello World</display_text>
</general>
</afteremail>
</default>
</config>


Helper Data.php



<?php

namespace VendorModuleHelper;

use MagentoFrameworkAppHelperAbstractHelper;
use MagentoStoreModelScopeInterface;

class Data extends AbstractHelper
{

const XML_PATH_AFTEREMAIL = 'afteremail/';

public function getConfigValue($field, $storeId = null)
{
return $this->scopeConfig->getValue(
$field, ScopeInterface::SCOPE_STORE, $storeId
);
}

public function getGeneralConfig($code, $storeId = null)
{

return $this->getConfigValue(self::XML_PATH_AFTEREMAIL .'general/'. $code, $storeId);
}

}


As well as Plugin.php



<?php

namespace VendorModulePlugin;

use MagentoEmailControllerAdminhtmlEmailTemplateDefaultTemplate;

class AddText
{
/**
* @var MagentoFrameworkSerializeSerializerJson
*/
protected $serializer;

protected $helperData;

public function __construct(
MagentoFrameworkSerializeSerializerJson $serializer,
VendorModuleHelperData $helperData
) {
$this->serializer = $serializer;
$this->helperData = $helperData;
}

/**
* @param DefaultTemplate $template
* @param $result
*/
public function afterExecute(DefaultTemplate $template, $result)
{
$displayText = $this->helperData->getGeneralConfig('display_text');
/** @var MagentoFrameworkAppResponseHttp $response */
$response = $template->getResponse();
$body = $this->serializer->unserialize($response->getBody());

$body['template_text'] .= PHP_EOL . PHP_EOL . $displayText;

$response->representJson(
$this->serializer->serialize($body)
);
}
}


For now, additional text displays out of email container.
I want to achieve that it displays in the container.
Any suggestions on how to do that will be highly appreciated!
Thanks!










share|improve this question























  • You can try another way to do that. Create a custom variable from Magento Admin panel, insert your text on that custom variable. then create a new footer template and insert your custom variable on the new footer email template. Please see this URL bsscommerce.com/blog/customize--magento-2-footer-template

    – Pritam Info 24
    10 hours ago











  • This method partly solves my task, but the idea is to edit text in the config tab. I suppose there is no option to update variable text from config tab.

    – Rufus
    10 hours ago














0












0








0








This is my system.xml file:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="afteremail" translate="label" sortOrder="10">
<label>Label</label>
</tab>
<section id="afteremail" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>After Email</label>
<tab>afteremail</tab>
<resource>Module_Vendor::afteremail_config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Display Text</label>
<comment>This text will display on the all transactional emails.</comment>
</field>
</group>
</section>
</system>
</config>


And config.xml:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<afteremail>
<general>
<display_text>Hello World</display_text>
</general>
</afteremail>
</default>
</config>


Helper Data.php



<?php

namespace VendorModuleHelper;

use MagentoFrameworkAppHelperAbstractHelper;
use MagentoStoreModelScopeInterface;

class Data extends AbstractHelper
{

const XML_PATH_AFTEREMAIL = 'afteremail/';

public function getConfigValue($field, $storeId = null)
{
return $this->scopeConfig->getValue(
$field, ScopeInterface::SCOPE_STORE, $storeId
);
}

public function getGeneralConfig($code, $storeId = null)
{

return $this->getConfigValue(self::XML_PATH_AFTEREMAIL .'general/'. $code, $storeId);
}

}


As well as Plugin.php



<?php

namespace VendorModulePlugin;

use MagentoEmailControllerAdminhtmlEmailTemplateDefaultTemplate;

class AddText
{
/**
* @var MagentoFrameworkSerializeSerializerJson
*/
protected $serializer;

protected $helperData;

public function __construct(
MagentoFrameworkSerializeSerializerJson $serializer,
VendorModuleHelperData $helperData
) {
$this->serializer = $serializer;
$this->helperData = $helperData;
}

/**
* @param DefaultTemplate $template
* @param $result
*/
public function afterExecute(DefaultTemplate $template, $result)
{
$displayText = $this->helperData->getGeneralConfig('display_text');
/** @var MagentoFrameworkAppResponseHttp $response */
$response = $template->getResponse();
$body = $this->serializer->unserialize($response->getBody());

$body['template_text'] .= PHP_EOL . PHP_EOL . $displayText;

$response->representJson(
$this->serializer->serialize($body)
);
}
}


For now, additional text displays out of email container.
I want to achieve that it displays in the container.
Any suggestions on how to do that will be highly appreciated!
Thanks!










share|improve this question














This is my system.xml file:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="afteremail" translate="label" sortOrder="10">
<label>Label</label>
</tab>
<section id="afteremail" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>After Email</label>
<tab>afteremail</tab>
<resource>Module_Vendor::afteremail_config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Display Text</label>
<comment>This text will display on the all transactional emails.</comment>
</field>
</group>
</section>
</system>
</config>


And config.xml:



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<afteremail>
<general>
<display_text>Hello World</display_text>
</general>
</afteremail>
</default>
</config>


Helper Data.php



<?php

namespace VendorModuleHelper;

use MagentoFrameworkAppHelperAbstractHelper;
use MagentoStoreModelScopeInterface;

class Data extends AbstractHelper
{

const XML_PATH_AFTEREMAIL = 'afteremail/';

public function getConfigValue($field, $storeId = null)
{
return $this->scopeConfig->getValue(
$field, ScopeInterface::SCOPE_STORE, $storeId
);
}

public function getGeneralConfig($code, $storeId = null)
{

return $this->getConfigValue(self::XML_PATH_AFTEREMAIL .'general/'. $code, $storeId);
}

}


As well as Plugin.php



<?php

namespace VendorModulePlugin;

use MagentoEmailControllerAdminhtmlEmailTemplateDefaultTemplate;

class AddText
{
/**
* @var MagentoFrameworkSerializeSerializerJson
*/
protected $serializer;

protected $helperData;

public function __construct(
MagentoFrameworkSerializeSerializerJson $serializer,
VendorModuleHelperData $helperData
) {
$this->serializer = $serializer;
$this->helperData = $helperData;
}

/**
* @param DefaultTemplate $template
* @param $result
*/
public function afterExecute(DefaultTemplate $template, $result)
{
$displayText = $this->helperData->getGeneralConfig('display_text');
/** @var MagentoFrameworkAppResponseHttp $response */
$response = $template->getResponse();
$body = $this->serializer->unserialize($response->getBody());

$body['template_text'] .= PHP_EOL . PHP_EOL . $displayText;

$response->representJson(
$this->serializer->serialize($body)
);
}
}


For now, additional text displays out of email container.
I want to achieve that it displays in the container.
Any suggestions on how to do that will be highly appreciated!
Thanks!







magento2 email-templates






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 11 hours ago









RufusRufus

1366




1366













  • You can try another way to do that. Create a custom variable from Magento Admin panel, insert your text on that custom variable. then create a new footer template and insert your custom variable on the new footer email template. Please see this URL bsscommerce.com/blog/customize--magento-2-footer-template

    – Pritam Info 24
    10 hours ago











  • This method partly solves my task, but the idea is to edit text in the config tab. I suppose there is no option to update variable text from config tab.

    – Rufus
    10 hours ago



















  • You can try another way to do that. Create a custom variable from Magento Admin panel, insert your text on that custom variable. then create a new footer template and insert your custom variable on the new footer email template. Please see this URL bsscommerce.com/blog/customize--magento-2-footer-template

    – Pritam Info 24
    10 hours ago











  • This method partly solves my task, but the idea is to edit text in the config tab. I suppose there is no option to update variable text from config tab.

    – Rufus
    10 hours ago

















You can try another way to do that. Create a custom variable from Magento Admin panel, insert your text on that custom variable. then create a new footer template and insert your custom variable on the new footer email template. Please see this URL bsscommerce.com/blog/customize--magento-2-footer-template

– Pritam Info 24
10 hours ago





You can try another way to do that. Create a custom variable from Magento Admin panel, insert your text on that custom variable. then create a new footer template and insert your custom variable on the new footer email template. Please see this URL bsscommerce.com/blog/customize--magento-2-footer-template

– Pritam Info 24
10 hours ago













This method partly solves my task, but the idea is to edit text in the config tab. I suppose there is no option to update variable text from config tab.

– Rufus
10 hours ago





This method partly solves my task, but the idea is to edit text in the config tab. I suppose there is no option to update variable text from config tab.

– Rufus
10 hours ago










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269909%2fadd-additional-text-to-email-template-container%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269909%2fadd-additional-text-to-email-template-container%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Alcázar de San Juan

Griza ansero

Heinkel He 51