I have created module to get order_id to get some custom information from database.
events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="email_order_set_template_vars_before">
<observer name="add_custom_variable_to_Order"
instance="Customedit\GetOrder\Observer\ObserverforAddCustomVariable"/>
</event>
ObserverforAddCustomVariable.php
namespace Customedit\GetOrder\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\App\ObjectManager;
class ObserverforAddCustomVariable implements ObserverInterface
{
public function __construct()
{
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
$transport = $observer->getTransport();
$order = $transport->getOrder()->getId();
$transport['Get_OrderId'] = $order;
}
}
Now, I want to check that I can get orderId with
{{var Get_OrderId}}
it returned nothing.
Did I use wrong method or did something wrong?
If I can't get order_id. Can I get increment_id instead?