1

How do I add the value of an order attribute to the New Order Email template. Specifically an attribute called delivery_date stored in sales_order_grid.

I tried to reverse engineer how {{var order.getShippingDescription()}} works but with no success.

EDIT: I should add that another method I tried was by editing the Email Templates...

vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml

...and adding this line to it.

$deliverydate = $order->getDeliveryDate()

(Hoping that I could grab the data the same way that I'd grab a Product Attribute). But that method also returned no value.

2
  • IS delivery_date the field of sales_order table?
    – Amit Bera
    Commented Mar 20, 2019 at 13:43
  • Yes, delivery_date is also in the sales_order table
    – Craig
    Commented Mar 20, 2019 at 14:04

1 Answer 1

0

you should use the email_order_set_template_vars_before event.

write an observer for the event and add you desired data. then in the email template you have to add the data.

3
  • Please, can you elaborate on that?
    – Craig
    Commented Mar 20, 2019 at 14:02
  • @Craig done. it's pretty simple Commented Mar 20, 2019 at 14:08
  • Ok, I'll look into into it - Cheers
    – Craig
    Commented Mar 20, 2019 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.