5

The problem is that I am sending the Magento order to an external ERP and they need the customer id from Magento.

the problem comes when the customer is guest because in theory this customer doesn't have an id but I am not sure. Is there a way to check if the customer is a guest?

I am using the Mage_Sales_Model_Order object in order to get the information I need from the customer.

Thanks!

2

if you just want to know if the customer is guest or not. trigger getCustomerIsGuest() in Mage_Sales_Model_Order I believe that can get customer instance of order.

7

as you said I am using the Mage_Sales_Model_Order object in order to get the information then:

if($order->getCustomerIsGuest()){
    // customer is guest
}else{
    $customerid = $order->getCustomer()->getId();
    //send the customer id to your external ERP
}
1
  • Hi, thanks for your help, I was wondering if this really existed. I am going to check this and see if it works.
    – apz2000
    May 9 '14 at 22:53
0

This can also be checked by observer:

$order = $observer->getEvent()->getOrder(); 
$guestCustomer = $order->getCustomerIsGuest();
groupId  = $order->getCustomerGroupId();

we can get all type of customer data using observer.

0

Here is a way to do it in SQL, for one customer.

select
   entity_id,
   increment_id,
   customer_is_guest
from
   sales_flat_order
where
   increment_id = 101125260
;

Outputs:

+-----------+--------------+-------------------+
| entity_id | increment_id | customer_is_guest |
+-----------+--------------+-------------------+
|   2371223 | 101125260    |                 1 |
+-----------+--------------+-------------------+

To generate a histogram and understand the percentage of your users which are logged in when checking out.

select
   if(customer_id, 1, 0) as loggedin,
   count(*)
from
   sales_flat_order
where
   created_at > '2018-11-01'
group by
   1
order by
   1 desc
;

Outputs:

+----------+----------+
| loggedin | count(*) |
+----------+----------+
|        1 |     1194 |
|        0 |     1693 |
+----------+----------+

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.