0

I have added a custom attribute for storing additional emails for customers.

By default, when an order is placed, the customer_email field in sales_order table is taking from the email field from customer_entity. However, I need the customer_email field to use my custom attribute.

How can I do this?

1

You need to do following thins.

  1. Use "sales_order_place_after" event in your custom extension.

  2. In code, get value of customer_email using order object and save value into your custom_attribute as well.

| improve this answer | |
  • When using sales_order_place_after event, can I get my custom attribute from \Magento\Customer\Model\Session $customerSession? – Magento Learner Apr 24 '18 at 13:56
  • You can load customer by email and used any custom attribute value of that customer associated with order. – Dhiren Vasoya Apr 24 '18 at 14:04
0

This is my solution,

  1. I use event sales_order_place_after in my custom module.

  2. I used this solution to get my customer custom attribute and set it to customer_email in sales_order table

| improve this answer | |

Your Answer

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

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