Maganto 2 | Does guest customer Id exists ? if yes how can we get through Order collection or some other way?
-
06-02-2021 - |
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
La 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
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange