How to set values of billing info and shipping info in custom email templates? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How to set custom value in default Email template Magento 2Change shipping method names in email templates in magentoIn my custom confirmation email template password is not displayingHow to set values in custom email templates?How can i send Company logo in custom email templatesMagento 2 : How to handle array values in custom email templates?Magento 2: How to call Email template in email templates?Magento 2.1.6 - How to setup email templates header and footerEdit billing and shipping address in email templateSet custom shipment email template, for spesific shipping methodMagento 2. Use same email templates for emails sent from admin and frontend without duplicating the templates

Determine the generator of an ideal of ring of integers

Putting Ant-Man on house arrest

Converting a text document with special format to Pandas DataFrame

What is the definining line between a helicopter and a drone a person can ride in?

Is the Mordenkainen's Sword spell underpowered?

Why do people think Winterfell crypts is the safest place for women, children & old people?

Suing a Police Officer Instead of the Police Department

How is an IPA symbol that lacks a name (e.g. ɲ) called?

Is "ein Herz wie das meine" an antiquated or colloquial use of the possesive pronoun?

/bin/ls sorts differently than just ls

How can I introduce the names of fantasy creatures to the reader?

Recursive calls to a function - why is the address of the parameter passed to it lowering with each call?

lm and glm function in R

How was Lagrange appointed professor of mathematics so early?

Proving inequality for positive definite matrix

“Since the train was delayed for more than an hour, passengers were given a full refund.” – Why is there no article before “passengers”?

Can the van der Waals coefficients be negative in the van der Waals equation for real gases?

What is the evidence that custom checks in Northern Ireland are going to result in violence?

What is the ongoing value of the Kanban board to the developers as opposed to management

Why doesn't the university give past final exams' answers?

If gravity precedes the formation of a solar system, where did the mass come from that caused the gravity?

Why do C and C++ allow the expression (int) + 4*5?

Trying to enter the Fox's den

How to charge percentage of transaction cost?



How to set values of billing info and shipping info in custom email templates?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How to set custom value in default Email template Magento 2Change shipping method names in email templates in magentoIn my custom confirmation email template password is not displayingHow to set values in custom email templates?How can i send Company logo in custom email templatesMagento 2 : How to handle array values in custom email templates?Magento 2: How to call Email template in email templates?Magento 2.1.6 - How to setup email templates header and footerEdit billing and shipping address in email templateSet custom shipment email template, for spesific shipping methodMagento 2. Use same email templates for emails sent from admin and frontend without duplicating the templates



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








2















This is my email_template.html



 <table class="order-details">
<tr>
<td class="address-details">
<h3>trans "Billing Info"</h3>
<p>var formattedBillingAddress</p>
</td>
depend order.getIsNotVirtual()
<td class="address-details">
<h3>trans "Shipping Info"</h3>
<p>raw</p>
</td>
/depend
</tr>
</table>


and in my observer



$templateVars = array(
'store' => $this->storeManager->getStore(),
'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
'order' => $order,
'store'=> $store,
'productName'=> $productName
);

->setTemplateVars($templateVars)


My question is how can i set values of billing info, shipping info and payment method in this email template.










share|improve this question
























  • Which is event you catch?

    – Khoa TruongDinh
    Sep 16 '16 at 4:42











  • checkout_onepage_controller_success_action

    – Ramkishan Suthar
    Sep 16 '16 at 4:44











  • @Ramkishan you ask how to pass/set value in email templates? or how to get values in observer?

    – Bilal Usean
    Sep 16 '16 at 4:54











  • @Ramkishan, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

    – Vigna S
    Mar 1 '17 at 13:27












  • You should ask a new question @Vigna. beacuase in comments i can't explain you whole thing.

    – Ramkishan Suthar
    Mar 2 '17 at 4:06

















2















This is my email_template.html



 <table class="order-details">
<tr>
<td class="address-details">
<h3>trans "Billing Info"</h3>
<p>var formattedBillingAddress</p>
</td>
depend order.getIsNotVirtual()
<td class="address-details">
<h3>trans "Shipping Info"</h3>
<p>raw</p>
</td>
/depend
</tr>
</table>


and in my observer



$templateVars = array(
'store' => $this->storeManager->getStore(),
'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
'order' => $order,
'store'=> $store,
'productName'=> $productName
);

->setTemplateVars($templateVars)


My question is how can i set values of billing info, shipping info and payment method in this email template.










share|improve this question
























  • Which is event you catch?

    – Khoa TruongDinh
    Sep 16 '16 at 4:42











  • checkout_onepage_controller_success_action

    – Ramkishan Suthar
    Sep 16 '16 at 4:44











  • @Ramkishan you ask how to pass/set value in email templates? or how to get values in observer?

    – Bilal Usean
    Sep 16 '16 at 4:54











  • @Ramkishan, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

    – Vigna S
    Mar 1 '17 at 13:27












  • You should ask a new question @Vigna. beacuase in comments i can't explain you whole thing.

    – Ramkishan Suthar
    Mar 2 '17 at 4:06













2












2








2








This is my email_template.html



 <table class="order-details">
<tr>
<td class="address-details">
<h3>trans "Billing Info"</h3>
<p>var formattedBillingAddress</p>
</td>
depend order.getIsNotVirtual()
<td class="address-details">
<h3>trans "Shipping Info"</h3>
<p>raw</p>
</td>
/depend
</tr>
</table>


and in my observer



$templateVars = array(
'store' => $this->storeManager->getStore(),
'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
'order' => $order,
'store'=> $store,
'productName'=> $productName
);

->setTemplateVars($templateVars)


My question is how can i set values of billing info, shipping info and payment method in this email template.










share|improve this question
















This is my email_template.html



 <table class="order-details">
<tr>
<td class="address-details">
<h3>trans "Billing Info"</h3>
<p>var formattedBillingAddress</p>
</td>
depend order.getIsNotVirtual()
<td class="address-details">
<h3>trans "Shipping Info"</h3>
<p>raw</p>
</td>
/depend
</tr>
</table>


and in my observer



$templateVars = array(
'store' => $this->storeManager->getStore(),
'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
'order' => $order,
'store'=> $store,
'productName'=> $productName
);

->setTemplateVars($templateVars)


My question is how can i set values of billing info, shipping info and payment method in this email template.







magento2 email-templates






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 16 '16 at 5:03









Khoa TruongDinh

22.3k64187




22.3k64187










asked Sep 16 '16 at 4:38









Ramkishan SutharRamkishan Suthar

2,28221435




2,28221435












  • Which is event you catch?

    – Khoa TruongDinh
    Sep 16 '16 at 4:42











  • checkout_onepage_controller_success_action

    – Ramkishan Suthar
    Sep 16 '16 at 4:44











  • @Ramkishan you ask how to pass/set value in email templates? or how to get values in observer?

    – Bilal Usean
    Sep 16 '16 at 4:54











  • @Ramkishan, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

    – Vigna S
    Mar 1 '17 at 13:27












  • You should ask a new question @Vigna. beacuase in comments i can't explain you whole thing.

    – Ramkishan Suthar
    Mar 2 '17 at 4:06

















  • Which is event you catch?

    – Khoa TruongDinh
    Sep 16 '16 at 4:42











  • checkout_onepage_controller_success_action

    – Ramkishan Suthar
    Sep 16 '16 at 4:44











  • @Ramkishan you ask how to pass/set value in email templates? or how to get values in observer?

    – Bilal Usean
    Sep 16 '16 at 4:54











  • @Ramkishan, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

    – Vigna S
    Mar 1 '17 at 13:27












  • You should ask a new question @Vigna. beacuase in comments i can't explain you whole thing.

    – Ramkishan Suthar
    Mar 2 '17 at 4:06
















Which is event you catch?

– Khoa TruongDinh
Sep 16 '16 at 4:42





Which is event you catch?

– Khoa TruongDinh
Sep 16 '16 at 4:42













checkout_onepage_controller_success_action

– Ramkishan Suthar
Sep 16 '16 at 4:44





checkout_onepage_controller_success_action

– Ramkishan Suthar
Sep 16 '16 at 4:44













@Ramkishan you ask how to pass/set value in email templates? or how to get values in observer?

– Bilal Usean
Sep 16 '16 at 4:54





@Ramkishan you ask how to pass/set value in email templates? or how to get values in observer?

– Bilal Usean
Sep 16 '16 at 4:54













@Ramkishan, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

– Vigna S
Mar 1 '17 at 13:27






@Ramkishan, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

– Vigna S
Mar 1 '17 at 13:27














You should ask a new question @Vigna. beacuase in comments i can't explain you whole thing.

– Ramkishan Suthar
Mar 2 '17 at 4:06





You should ask a new question @Vigna. beacuase in comments i can't explain you whole thing.

– Ramkishan Suthar
Mar 2 '17 at 4:06










3 Answers
3






active

oldest

votes


















1














Inject class Renderer used for formatting an order address and some classes for Payment into your constructor.



/**
* @var MagentoSalesModelOrderAddressRenderer
*/
protected $addressRenderer;

/**
* @var MagentoPaymentHelperPaymentHelper
*/
protected $paymentHelper;

public function __construct(
MagentoSalesModelOrderAddressRenderer $addressRenderer,
MagentoPaymentHelperPaymentHelper $paymentHelper
)
$this->addressRenderer = $addressRenderer;
$this->paymentHelper = $paymentHelper;



Add to $templateVars:



$templateVars = array(
'store' => $this->storeManager->getStore(),
'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
'order' => $order,
'store'=> $store,
'productName'=> $productName,
'payment_html' => $this->getPaymentHtml($order),
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
);


Build the methodes for shippping , billing address and payment:



/**
* @param Order $order
* @return string|null
*/
protected function getFormattedShippingAddress($order)

return $order->getIsVirtual()
? null
: $this->addressRenderer->format($order->getShippingAddress(), 'html');


/**
* @param Order $order
* @return string|null
*/
protected function getFormattedBillingAddress($order)

return $this->addressRenderer->format($order->getBillingAddress(), 'html');


/**
* Get payment info block as html
*
* @param Order $order
* @return string
*/
protected function getPaymentHtml(Order $order)

return $this->paymentHelper->getInfoBlockHtml(
$order->getPayment(),
$this->identityContainer->getStore()->getStoreId()
);



See a good sample here:



vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php
vendor/magento/module-sales/view/frontend/email/order_new.html






share|improve this answer

























  • Thank you @Khoa i got the values. your post was very helpful.

    – Ramkishan Suthar
    Sep 16 '16 at 5:29











  • @Khoa TruongDinh, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

    – Vigna S
    Mar 1 '17 at 13:30


















0














$templateVars = array(
'store' => $this->storeManager->getStore(),
'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
'order' => $order,
'store'=> $store,
'productName'=> $productName
);


you can use the above variable in email templates like



for write static text you can use -> trans "Dear"



for include variable you can use -> var productName



for example you greet your customer in mail templates like



<h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">trans "Dear " var customer_name,</h1>


In this above example customer name is the $templateVars array index. You need to get customer name from observer after that you can pass that value into $templateVars array.






share|improve this answer

























  • i need to print billing info and shipping info in my templates. how can i do this ?

    – Ramkishan Suthar
    Sep 16 '16 at 4:52











  • do you get that values in observer? pls show your full observer code

    – Bilal Usean
    Sep 16 '16 at 4:54



















0














For magento 2.3, replace this



MagentoPaymentHelperPaymentHelper $paymentHelper


with



MagentoPaymentHelperData $paymentHelper





share|improve this answer








New contributor




Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    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%2f136622%2fhow-to-set-values-of-billing-info-and-shipping-info-in-custom-email-templates%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Inject class Renderer used for formatting an order address and some classes for Payment into your constructor.



    /**
    * @var MagentoSalesModelOrderAddressRenderer
    */
    protected $addressRenderer;

    /**
    * @var MagentoPaymentHelperPaymentHelper
    */
    protected $paymentHelper;

    public function __construct(
    MagentoSalesModelOrderAddressRenderer $addressRenderer,
    MagentoPaymentHelperPaymentHelper $paymentHelper
    )
    $this->addressRenderer = $addressRenderer;
    $this->paymentHelper = $paymentHelper;



    Add to $templateVars:



    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName,
    'payment_html' => $this->getPaymentHtml($order),
    'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
    'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
    );


    Build the methodes for shippping , billing address and payment:



    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedShippingAddress($order)

    return $order->getIsVirtual()
    ? null
    : $this->addressRenderer->format($order->getShippingAddress(), 'html');


    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedBillingAddress($order)

    return $this->addressRenderer->format($order->getBillingAddress(), 'html');


    /**
    * Get payment info block as html
    *
    * @param Order $order
    * @return string
    */
    protected function getPaymentHtml(Order $order)

    return $this->paymentHelper->getInfoBlockHtml(
    $order->getPayment(),
    $this->identityContainer->getStore()->getStoreId()
    );



    See a good sample here:



    vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php
    vendor/magento/module-sales/view/frontend/email/order_new.html






    share|improve this answer

























    • Thank you @Khoa i got the values. your post was very helpful.

      – Ramkishan Suthar
      Sep 16 '16 at 5:29











    • @Khoa TruongDinh, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

      – Vigna S
      Mar 1 '17 at 13:30















    1














    Inject class Renderer used for formatting an order address and some classes for Payment into your constructor.



    /**
    * @var MagentoSalesModelOrderAddressRenderer
    */
    protected $addressRenderer;

    /**
    * @var MagentoPaymentHelperPaymentHelper
    */
    protected $paymentHelper;

    public function __construct(
    MagentoSalesModelOrderAddressRenderer $addressRenderer,
    MagentoPaymentHelperPaymentHelper $paymentHelper
    )
    $this->addressRenderer = $addressRenderer;
    $this->paymentHelper = $paymentHelper;



    Add to $templateVars:



    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName,
    'payment_html' => $this->getPaymentHtml($order),
    'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
    'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
    );


    Build the methodes for shippping , billing address and payment:



    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedShippingAddress($order)

    return $order->getIsVirtual()
    ? null
    : $this->addressRenderer->format($order->getShippingAddress(), 'html');


    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedBillingAddress($order)

    return $this->addressRenderer->format($order->getBillingAddress(), 'html');


    /**
    * Get payment info block as html
    *
    * @param Order $order
    * @return string
    */
    protected function getPaymentHtml(Order $order)

    return $this->paymentHelper->getInfoBlockHtml(
    $order->getPayment(),
    $this->identityContainer->getStore()->getStoreId()
    );



    See a good sample here:



    vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php
    vendor/magento/module-sales/view/frontend/email/order_new.html






    share|improve this answer

























    • Thank you @Khoa i got the values. your post was very helpful.

      – Ramkishan Suthar
      Sep 16 '16 at 5:29











    • @Khoa TruongDinh, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

      – Vigna S
      Mar 1 '17 at 13:30













    1












    1








    1







    Inject class Renderer used for formatting an order address and some classes for Payment into your constructor.



    /**
    * @var MagentoSalesModelOrderAddressRenderer
    */
    protected $addressRenderer;

    /**
    * @var MagentoPaymentHelperPaymentHelper
    */
    protected $paymentHelper;

    public function __construct(
    MagentoSalesModelOrderAddressRenderer $addressRenderer,
    MagentoPaymentHelperPaymentHelper $paymentHelper
    )
    $this->addressRenderer = $addressRenderer;
    $this->paymentHelper = $paymentHelper;



    Add to $templateVars:



    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName,
    'payment_html' => $this->getPaymentHtml($order),
    'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
    'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
    );


    Build the methodes for shippping , billing address and payment:



    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedShippingAddress($order)

    return $order->getIsVirtual()
    ? null
    : $this->addressRenderer->format($order->getShippingAddress(), 'html');


    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedBillingAddress($order)

    return $this->addressRenderer->format($order->getBillingAddress(), 'html');


    /**
    * Get payment info block as html
    *
    * @param Order $order
    * @return string
    */
    protected function getPaymentHtml(Order $order)

    return $this->paymentHelper->getInfoBlockHtml(
    $order->getPayment(),
    $this->identityContainer->getStore()->getStoreId()
    );



    See a good sample here:



    vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php
    vendor/magento/module-sales/view/frontend/email/order_new.html






    share|improve this answer















    Inject class Renderer used for formatting an order address and some classes for Payment into your constructor.



    /**
    * @var MagentoSalesModelOrderAddressRenderer
    */
    protected $addressRenderer;

    /**
    * @var MagentoPaymentHelperPaymentHelper
    */
    protected $paymentHelper;

    public function __construct(
    MagentoSalesModelOrderAddressRenderer $addressRenderer,
    MagentoPaymentHelperPaymentHelper $paymentHelper
    )
    $this->addressRenderer = $addressRenderer;
    $this->paymentHelper = $paymentHelper;



    Add to $templateVars:



    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName,
    'payment_html' => $this->getPaymentHtml($order),
    'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
    'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
    );


    Build the methodes for shippping , billing address and payment:



    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedShippingAddress($order)

    return $order->getIsVirtual()
    ? null
    : $this->addressRenderer->format($order->getShippingAddress(), 'html');


    /**
    * @param Order $order
    * @return string|null
    */
    protected function getFormattedBillingAddress($order)

    return $this->addressRenderer->format($order->getBillingAddress(), 'html');


    /**
    * Get payment info block as html
    *
    * @param Order $order
    * @return string
    */
    protected function getPaymentHtml(Order $order)

    return $this->paymentHelper->getInfoBlockHtml(
    $order->getPayment(),
    $this->identityContainer->getStore()->getStoreId()
    );



    See a good sample here:



    vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php
    vendor/magento/module-sales/view/frontend/email/order_new.html







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 16 '16 at 5:01

























    answered Sep 16 '16 at 4:51









    Khoa TruongDinhKhoa TruongDinh

    22.3k64187




    22.3k64187












    • Thank you @Khoa i got the values. your post was very helpful.

      – Ramkishan Suthar
      Sep 16 '16 at 5:29











    • @Khoa TruongDinh, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

      – Vigna S
      Mar 1 '17 at 13:30

















    • Thank you @Khoa i got the values. your post was very helpful.

      – Ramkishan Suthar
      Sep 16 '16 at 5:29











    • @Khoa TruongDinh, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

      – Vigna S
      Mar 1 '17 at 13:30
















    Thank you @Khoa i got the values. your post was very helpful.

    – Ramkishan Suthar
    Sep 16 '16 at 5:29





    Thank you @Khoa i got the values. your post was very helpful.

    – Ramkishan Suthar
    Sep 16 '16 at 5:29













    @Khoa TruongDinh, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

    – Vigna S
    Mar 1 '17 at 13:30





    @Khoa TruongDinh, My observer file has code like below, $transport = $objectManager->create('MagentoFrameworkMailTemplateTransportBuilder'); $templateVars = array( 'myvar1' => 'testing data' ); $transport->setTemplateVars($templateVars); But could't retrive this value in my Email... In Email template , var myvar1

    – Vigna S
    Mar 1 '17 at 13:30













    0














    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName
    );


    you can use the above variable in email templates like



    for write static text you can use -> trans "Dear"



    for include variable you can use -> var productName



    for example you greet your customer in mail templates like



    <h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">trans "Dear " var customer_name,</h1>


    In this above example customer name is the $templateVars array index. You need to get customer name from observer after that you can pass that value into $templateVars array.






    share|improve this answer

























    • i need to print billing info and shipping info in my templates. how can i do this ?

      – Ramkishan Suthar
      Sep 16 '16 at 4:52











    • do you get that values in observer? pls show your full observer code

      – Bilal Usean
      Sep 16 '16 at 4:54
















    0














    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName
    );


    you can use the above variable in email templates like



    for write static text you can use -> trans "Dear"



    for include variable you can use -> var productName



    for example you greet your customer in mail templates like



    <h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">trans "Dear " var customer_name,</h1>


    In this above example customer name is the $templateVars array index. You need to get customer name from observer after that you can pass that value into $templateVars array.






    share|improve this answer

























    • i need to print billing info and shipping info in my templates. how can i do this ?

      – Ramkishan Suthar
      Sep 16 '16 at 4:52











    • do you get that values in observer? pls show your full observer code

      – Bilal Usean
      Sep 16 '16 at 4:54














    0












    0








    0







    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName
    );


    you can use the above variable in email templates like



    for write static text you can use -> trans "Dear"



    for include variable you can use -> var productName



    for example you greet your customer in mail templates like



    <h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">trans "Dear " var customer_name,</h1>


    In this above example customer name is the $templateVars array index. You need to get customer name from observer after that you can pass that value into $templateVars array.






    share|improve this answer















    $templateVars = array(
    'store' => $this->storeManager->getStore(),
    'message' => 'We processed your order ID We will contact you soon in mail for the acknowledgement if you not receive mail within 4 hours please get help from support@xxx.com',
    'order' => $order,
    'store'=> $store,
    'productName'=> $productName
    );


    you can use the above variable in email templates like



    for write static text you can use -> trans "Dear"



    for include variable you can use -> var productName



    for example you greet your customer in mail templates like



    <h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">trans "Dear " var customer_name,</h1>


    In this above example customer name is the $templateVars array index. You need to get customer name from observer after that you can pass that value into $templateVars array.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 16 '16 at 5:23

























    answered Sep 16 '16 at 4:49









    Bilal UseanBilal Usean

    5,16043992




    5,16043992












    • i need to print billing info and shipping info in my templates. how can i do this ?

      – Ramkishan Suthar
      Sep 16 '16 at 4:52











    • do you get that values in observer? pls show your full observer code

      – Bilal Usean
      Sep 16 '16 at 4:54


















    • i need to print billing info and shipping info in my templates. how can i do this ?

      – Ramkishan Suthar
      Sep 16 '16 at 4:52











    • do you get that values in observer? pls show your full observer code

      – Bilal Usean
      Sep 16 '16 at 4:54

















    i need to print billing info and shipping info in my templates. how can i do this ?

    – Ramkishan Suthar
    Sep 16 '16 at 4:52





    i need to print billing info and shipping info in my templates. how can i do this ?

    – Ramkishan Suthar
    Sep 16 '16 at 4:52













    do you get that values in observer? pls show your full observer code

    – Bilal Usean
    Sep 16 '16 at 4:54






    do you get that values in observer? pls show your full observer code

    – Bilal Usean
    Sep 16 '16 at 4:54












    0














    For magento 2.3, replace this



    MagentoPaymentHelperPaymentHelper $paymentHelper


    with



    MagentoPaymentHelperData $paymentHelper





    share|improve this answer








    New contributor




    Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      0














      For magento 2.3, replace this



      MagentoPaymentHelperPaymentHelper $paymentHelper


      with



      MagentoPaymentHelperData $paymentHelper





      share|improve this answer








      New contributor




      Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















        0












        0








        0







        For magento 2.3, replace this



        MagentoPaymentHelperPaymentHelper $paymentHelper


        with



        MagentoPaymentHelperData $paymentHelper





        share|improve this answer








        New contributor




        Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        For magento 2.3, replace this



        MagentoPaymentHelperPaymentHelper $paymentHelper


        with



        MagentoPaymentHelperData $paymentHelper






        share|improve this answer








        New contributor




        Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Apr 18 at 9:58









        Tudor RogojanuTudor Rogojanu

        1




        1




        New contributor




        Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Tudor Rogojanu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























            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%2f136622%2fhow-to-set-values-of-billing-info-and-shipping-info-in-custom-email-templates%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

            Sum ergo cogito? 1 nng

            三茅街道4182Guuntc Dn precexpngmageondP