First, my apologies if this has been addressed elsewhere - I've searched and seen the posts regarding capturing the IP address for back-end purposes but hadn't seen anything quite exactly like this.
Also this may seem a bit pretentious to post in Custom Mods, (it's just a simple hack) so moderators please feel free to move to more appropriate forum.
It is also a good example/excercise of how you can use your own "pseudo" variables in any of your language variables.
Say for instance, you would like to display to a customer during checkout that their IP address is part of your anti-fraud technology -
please, let's skip the debate as to whether this is useful or not; some clients want this based on the high-risk markets they are in and feel it is at least a minor deterrent.
Okay, first create a new text label:
Administration -> Languages -> Select Language -> Select Topic -> Text
For variable put:
msg_customer_IP
For Description put:
Customer IP address
For Value use something like this (note the double curly brackets around the word customer_ip:
Code:
<font color=red>*NOTE*</font> Your IP address : {{customer_ip}} is tracked during the checkout process as part of our anti-fraud technology.
Then to display this information wherever you want, use:
Code:
{$lng.msg_customer_ip|substitute:"customer_ip":$smarty.server.REMOTE_ADDR}
I added this as the last line of skin1/customer/main/cart_totals.tpl thereby displaying during every step of the checkout process.
The "substitute" pipe replaces your pseudo variable "customer_ip" with the smarty global containing the remote IP address.
Credits go to PhilJ for putting me on to the smarty global thing:
http://forum.x-cart.com/viewtopic.php?t=14490&highlight=remoteaddr
I was trying to use a PHP global and couldn't get it to work quite right. Thanks Phil
