Question

I am getting guest customer Collection with:

\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory

as:

public function getGuestOrderCollection()
  {    
   $orderCollecion = $this->_orderCollectionFactory->create()->addFieldToSelect('*');
   $orderCollecion->addAttributeToFilter('customer_is_guest', ['eq'=>1]);
   return $orderCollecion;
  }

Currently I am not getting ID for guest customer by this but it works without guest customer:

$Id = $_order->getId();

I am looking to change guest customer information by this. Can any body help me to now about it. Thanks

Was it helpful?

Solution

There are no customer id returns for guest. The $Id you got is actually order_id. If you want to change the guest customer info, you can use the following code for an order:

$_order->setCustomerEmail("newemail@host.com"); //Set "Email"

If you want to modify the addresses, you can use the following code:

$bill_address = $order->getBillingAddress();
$bill_address->setTelephone(12345678);  //Set "Telephone" inside billing address
$ship_address = $order->getShippingAddress();
$ship_address->setTelephone(98765432);  //Set "Telephone" inside shipping address
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top