I have successfully created custom customer attributes in Magento 2.3.2 (like doctor name and doctor zipcode) and I can see/modify them in my adminhtml customer view. What I would like is to have them inserted into customer orders and order e-mails. Has anyone already done that ? Thank you for your pointers/hints/solutions ! Edit :

I tried using observers : 1 for customer signup, 1 on successful order. So I added 2 modules

One called CustomerRegister : registration.php :




<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <event name="customer_register_success">
<observer name="customerregister" instance="CustomerRegister\Emails\Observer\AddCustomerData">


?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="CustomerRegister" setup_version="1.0.1">
<module name="Magento_CustomerRegister"/>

Observer/AddCustomerData.php :


namespace Anshu\Emails\Observer;

use Magento\Framework\Event\ObserverInterface;

class AddCustomerData implements ObserverInterface
 public function __construct(
    \Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface
    $this->_customerRepositoryInterface = $customerRepositoryInterface;

  public function execute(\Magento\Framework\Event\Observer $observer)
    $transport = $observer->getEvent()->getTransport();
    $customer = $this->_customerRepositoryInterface->getById($transport->getOrder()->GetCustomerId());

'nommedecin' => $customer->getCustomAttribute('nommedecin')->getValue()


If I insert the {{ var nommedecin }} in my new customer email template, it's empty... If you have any clues, please do not hesitate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.