In the guest order info customer name displaying as a guest and looked into the database table of sales_order here customer first name & last name storing as a null.

how can we set name before place order?


Create one observer file :


namespace Namespace\Module\Observer;

use Magento\Framework\Event\ObserverInterface;

class SalesOrderPlaceBefore implements ObserverInterface

    public function execute(\Magento\Framework\Event\Observer $observer)
        $order = $observer->getEvent()->getOrder();
        if (!$order->getCustomerFirstname() && !$order->getCustomerLastname()) {
| improve this answer | |

You can do this by creating an observer similar to 'AssignOrderToCustomerObserver.php' in sales module.


This should work.

| improve this answer | |
  • Thank you for your answer. Actually, $customer->getFirstname() getting as blank value and I was solved by using observer after place order. – Praveen Chelumalla Aug 22 '19 at 4:08
  • Good to know :) – Sanjay Sharma Aug 22 '19 at 6:41

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.