I want to show delivery date in order-email template.I want to show in delivery date (today date + 10 day). How can I achieve that?


2 Answers 2


For this you need to create a simple module say Mago_Delivery. Create following files




<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Mago_Delivery" setup_version="1.0.1">


<?xml version="1.0"?>
    <preference for="Magento\Sales\Model\Order" type="Mago\Delivery\Model\Rewrite\Order" />



namespace Mago\Delivery\Model\Rewrite;

class Order extends \Magento\Sales\Model\Order

    public function getDeliveryDate()
        $orderDate = $this->getCreatedAt(); //ORDER CREATED DATE
        return date('Y-m-d', strtotime($orderDate. ' + 10 days'));


Finally in your email template you can get this date by:

{{var order.getDeliveryDate()}}

Note: I have created getDeliveryDate() function in general way, You can change it as per your requirement.

Hope above will help!

  • Thanks for this solution. Worked perfectly in M2.3.5.
    – Webninja
    Oct 7, 2020 at 8:23
  • @Webninja, Most welcome :)
    – Pawan
    Oct 7, 2020 at 8:25
  • 2
    Did not work for me in Magento ver. 2.3.6
    – TheFrakes
    Aug 24, 2021 at 11:41
  • @pawan, How can we change this to work with the new email variables of Magento? Because {{var order.getDeliveryDate()}} does not work anymore at the moment
    – JGeer
    Aug 6, 2022 at 12:36

In order to show delivery date in order Email, you have pass variables in your email function.

First, we need to get a delivery date in (today date + 10 days) format so for this you have to define the date in a construct like:

protected $date;

public function __construct(
    \Magento\Framework\Stdlib\DateTime\DateTime $date,
) {
    $this->date = $date;


$date = $this->date->gmtDate();

//////In Execute Function//////
$date = $this->date->gmtDate();

$DeliveryDate = date('Y-m-d', strtotime('+10 day', strtotime($date)));

$DeliveryDate will return (today date+10) date.

Pass $DeliveryDate variable in your Email function and use it in your email template.

  • How to use this codes? Can you eloborate your answer please,it will be helpful to me and fellow newbies,In ..vendor\magento\module-sales\Model\order.php created construct,where to edit execute function,which file..? Dec 18, 2021 at 5:56

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.