Why would a customer's IP address not show on orders sometimes?
Question
In the Dashboard: System > Configuration > Sales > Sales...
I have "Hide Customer IP: No"
and this means the customers IP is shown on orders and invoices, etc...
This works on almost every order, but a couple orders just don't show an IP at all. This is very rare, and maybe 1 out of every 100 orders don't show an IP.
Well, what would cause this? I was asked why this is, but I just didn't have an answer, and now I'm curious.
Thanks all.
Solution
Most probably the order was made from the back-end.
The ip address on the order comes from the quote.
in app/code/core/Mage/Sales/etc/config.xml
there is this:
<config>
...
<global>
...
<fieldsets>
...
<sales_convert_quote>
<remote_ip>
<to_order>*</to_order>
</remote_ip>
...
</sales_convert_quote>
...
</fieldsets>
...
</global>
...
</config>
The IP address on the quote is set in Mage_Checkout_Model_Session::getQuote()
if ($remoteAddr = Mage::helper('core/http')->getRemoteAddr()) {
$this->_quote->setRemoteIp($remoteAddr);
$xForwardIp = Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR');
$this->_quote->setXForwardedFor($xForwardIp);
}
When creating an order from the backend Mage_Checkout_Model_Session
is not used. Instead Mage_Adminhtml_Model_Session_Quote
is used and there is no trace of remoteIp
or remoteAddr
inside it.