Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Display Customer IP during checkout

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-09-2005, 06:31 AM
 
hooter hooter is offline
 

X-Adept
  
Join Date: Dec 2004
Posts: 519
 

Default Display Customer IP during checkout

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
__________________
Blog for X-Cart | Ebay Auction Manager
Reply With Quote
  #2  
Old 03-09-2005, 05:23 PM
 
x-online x-online is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Australia, Sydney
Posts: 189
 

Default

isn't this IP already intergrated with latest version?
if you go to order and click on whatever order you wanted you wil lsee
just under status: and tracking number:
IP address:
xxx.xxx.xxx.xxx
__________________
X-Cart version 4.x (Most likely will be the latest version)
Reply With Quote
  #3  
Old 03-09-2005, 05:56 PM
 
hooter hooter is offline
 

X-Adept
  
Join Date: Dec 2004
Posts: 519
 

Default

x-online,

Please read my post and its purpose carefully - this is for display to customer during checkout
__________________
Blog for X-Cart | Ebay Auction Manager
Reply With Quote
  #4  
Old 03-09-2005, 07:23 PM
 
x-online x-online is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Australia, Sydney
Posts: 189
 

Default

Sorry for my misreading ^_^''

Nice work!
__________________
X-Cart version 4.x (Most likely will be the latest version)
Reply With Quote
  #5  
Old 02-07-2006, 07:34 AM
 
simitpatel simitpatel is offline
 

Newbie
  
Join Date: Sep 2005
Posts: 7
 

Default small change

i just implemented this and had to make one small change. the code:
Code:
{$lng.msg_customer_ip|substitute:"customer_ip":$smarty.server.REMOTE_ADDR}

should be:
Code:
{$lng.msg_customer_IP|substitute:"customer_ip":$smarty.server.REMOTE_ADDR}
__________________
software: x-cart pro, Version 4.0.15
operating system: FreeBSD 5.4
Reply With Quote
  #6  
Old 02-07-2006, 09:04 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

I don't think the default takes Proxies or IP's behind LAN's into consideration. Here's a function that can easily be used in config.php to grab the absolute IP of the user. Thanks to NuLime for the function.
Code:
function fetch_remote_address() { $_SERVER = $GLOBALS['HTTP_SERVER_VARS']; # Record basic remote address. $remote_address = $_SERVER['REMOTE_ADDR']; # Take proxies into consideration or IPs behind a LAN. if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != 'unknown' && $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) { $HXFF_temp = preg_replace('/, ?unknown/i','',$_SERVER['HTTP_X_FORWARDED_FOR']); // Remove any trailing 'unknowns'. $remote_address .= ','.$HXFF_temp; } if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != 'unknown' && $_SERVER['HTTP_CLIENT_IP'] != $_SERVER['HTTP_X_FORWARDED_FOR'] && $_SERVER['HTTP_CLIENT_IP'] != $_SERVER['REMOTE_ADDR']) { $HCI_temp = preg_replace('/, ?unknown/i','',$_SERVER['HTTP_CLIENT_IP']); // Remove any trailing 'unknowns'. $remote_address .= ','.$HCI_temp; } return $remote_address; }
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote

The following user thanks B00MER for this useful post:
graffix (04-03-2012)
  #7  
Old 03-21-2006, 05:19 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default

Dear Boomer,
Where exactly to put this code in config.php ?

We need to just put this code & nothing else ? will it display the customer's original IP on chekout ?
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #8  
Old 03-21-2006, 06:45 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Quote:
Originally Posted by anandat
Dear Boomer,
Where exactly to put this code in config.php ?

We need to just put this code & nothing else ? will it display the customer's original IP on chekout ?

Place it towards the bottom of the file, before the WARNING comment.

Add this afterwards to call the IP anywhere:
Code:
$smarty->assign("customers_ip", fetch_remote_address());
And call the variable in any .tpl {$customers_ip}
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #9  
Old 04-13-2006, 07:01 PM
 
jbart976 jbart976 is offline
 

Member
  
Join Date: Mar 2005
Location: Miami
Posts: 13
 

Default

Place it towards the bottom of the file, before the WARNING comment.

Add this afterwards to call the IP anywhere:
Code:
$smarty->assign("customers_ip", fetch_remote_address());

And call the variable in any .tpl {$customers_ip}


Boomer, what do you mean by "And call the variable in any .tpl {$customers_ip}"

I copied the code into config like you said and added the line afterwards, but I'm still not seeing an IP.

Thanks.[/quote]
__________________
jbart976
X-Cart 4.0.12
Reply With Quote
  #10  
Old 04-13-2006, 11:40 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Code:
die(fetch_remote_address());
Add this after the function decleration in config.php, if it doesn't output anything than the function may need to use other GLOBAL variables, i.e. $HTTP_GET vs $_GET, etc.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:01 PM.

   

 
X-Cart forums © 2001-2020