7

Is there a way to tell if an order was placed through the frontend of the web site or entered through the administrative panel?

Chris
  • 1,731
  • 3
  • 24
  • 38

3 Answers3

12

By default, Magento only stores the remote_ip in table sales_flat_order for an order that is place by customer (while admin order is set to null).

So try this:

if(!empty($order->getRemoteIp()){
  //place online
}
else{
  // place by admin
}

See Programmatically differentiate between admin & customer-placed orders

Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62
8

Every order has a store_id, when entered through administraction it will either be 0 (for 'admin' store) or null.

if ($order->getStoreId()) {
    // was placed via frontend
}

Don't use getStore() as that won't always return the admin store object reliably.

Does not work with latest versions of Magento. (see comment)

Alex
  • 32,506
  • 16
  • 106
  • 171
clockworkgeek
  • 37,650
  • 9
  • 89
  • 127
  • 2
    clockworkgeek's answer is correct. I'll add one other way, that is mostly helpful to administrative users that aren't programmers. If you are looking at the order in the administration screen (Admin -> sales -> Orders) it will have a "Placed from IP" field if the order was created from the frontend, but if it was done through the admin backend screens it will not be there. – shaune Jan 05 '11 at 00:42
  • @sdek - That's a nice tip, I wasn't aware of it before. – clockworkgeek Jan 05 '11 at 01:06
  • 10
    Does not work with latest versions of Magento. You have to choose store id before create order within admin backend. So store_id will always have a value different from 0. – Yaroslav Rogoza Aug 08 '13 at 09:14
  • Yaroslav Rogoza is right! It will return the store id for which the order is placed, even from admin panel – Shathish Dec 24 '13 at 08:37
  • So can someone answer this question? – fortegente Jun 03 '14 at 14:10
0

You can check the is_super_mode value (I have only check on the quote : $quote->getIsSuperMode())

Wesley Bland
  • 8,816
  • 3
  • 44
  • 59