I have added a custom field in checkout form and saved that values in quote table. And also displayed in the backend in order details. Now I want to send that custom field value in email. I have used observer to do so. When static value is passed then it is printed in email but I am not getting any solution to get the custom field value from quote table and pass it in email. I am getting order id but from that order id please help/guide me to find the custom field value.
Below is my code
namespace Rishi\Emails\Observer;
use Magento\Framework\Event\ObserverInterface;
class AddMyData implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$transport = $observer->getTransport();
$order=$transport['order'];
$orderId=$order->getEntityId();
$transport['myvar'] = $orderId;
$transport['payment_html'] = 'myvar';
}
}
I have created a custom template and added {{var myvar|raw}}.
Please help me.