Check if order was created by customer or admin in Magento 2

0
1829
Check if order was created by customer or admin in Magento 2
Check if order was created by customer or admin in Magento 2

A little trick to check if order was created by customer or admin in Magento 2.

In Magento 2, by default, if order was created by customer the field remote_ip in sales_order will not be empty while it is NULL if it is placed by admin.

This is how to confirm:

if (!empty($order->getRemoteIp()) {
    // this order placed by customer
}
else{
    // this order placed by admin
}

Have fun!