Magento 1.7 – Programmatically Differentiate Between Admin & Customer-Placed Orders

magento-1.7orders

I'm trying to establish whether it is possible to differentiate between orders placed in the frontend (by the customer) and the backend (by an administrator).

I read this post on SO:

Differentiating Backend vs. Frontend Purchases in Magento

Which mainly highlights the fact that you used to be able to check the store_id field, but this does not hold true for the latest versions of Magento.

The other thing which it mentions is that when looking at an order via the backend, if it was indeed placed by a customer, you will see a field titled Placed from IP, which is missing if it was placed by an administrator.

I can't seem to find anything related to IP addresses via the sales_flat_order table.

Any ideas?

Best Answer

There is a field remote_ip on the table sales_flat_order, that appears to be null from the admin and the ip of the customer from the front end.

It was added in Magento 1.6 so if you are using version 1.7 you should be safe here.

It is set in app/code/core/Mage/Checkout/Model/Session.php on the quote and copied across.

<sales_convert_quote>
    <remote_ip>
        <to_order>*</to_order>
    </remote_ip>
</sales_convert_quote>
Related Topic