Maganto 2 | Does guest customer Id exists ? if yes how can we get through Order collection or some other way?

magento.stackexchange https://magento.stackexchange.com/questions/251416

문제

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

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top