Recording IP address in osCommerce
Alan asks;
Is it possible to record the ip address of each sale?
Alan, yes it is. But it is not standard osCommerce procedure to do so.
Adding an IP address recorder is really easy and is a simple modification that amnyone, and I mean ANYONE can make. There is a couple of IP contributions available already, but I thought it would make a decent tutorial for anyone wanting to get a bit "technical" with osCommerce.
The three files that we will be amending are;
- checkout_process.php
- admin/orders.php
- admin/includes/languages/english/orders.php
and we will be amending the orders table in the database to record the IP address.
Step 1: checkout_process.php
This file does the grunt work of recording orders made, so we need to add 1 line of code as so;
Find:
-
'currency_value' => $order->info['currency_value']);
Change to:
-
'currency_value' => $order->info['currency_value'],
-
'ip_address' => tep_get_ip_address());
Step 2: admin/orders.php
This files shows the orders made, we need to add a few pieces of code to this file.
Find:
Add this line of code directly underneath it:
Find:
-
$orders_query_raw = "select o.orders_id ............
Change to:
-
$orders_query_raw = "select o.ip_address, o.orders_id ...........
This is repeated another two times.
Find:
-
<td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td>
Add this line of code directly underneath it:
Step 3: admin/includes/languages/english/orders.php
Simply add this piece of code:
Step 4: Database changes
Run this SQL file to amend your database to allow it to record the IP address;
-
ALTER TABLE `orders` ADD `ip_address` VARCHAR( 20 ) NOT NULL;
That is it. If you have correctly made the changes, the buyers IP address will be recorded and will show in the order summary screen.



Nice and thanks a lot
Comment by john — July 20, 2008 @ 10:03 pm