Post by webcorvo » Thu Jun 08, 2017 5:53 am

For Customers Online Report works we must INSERT not update fields

Go to database and you must add a new filed on table oc_customer_online with AUTO_INCREMENT

or

DELETE the table oc_customer_online

and create a new one, run this SQL code

Code: Select all

CREATE TABLE `oc_customer_online` (
  `id` int(11) NOT NULL,
  `ip` varchar(40) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `url` text NOT NULL,
  `referer` text NOT NULL,
  `date_added` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

ALTER TABLE `oc_customer_online`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `oc_customer_online` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT; 

in catalog/model/tool/online.php

Code: Select all

$this->db->query("UPDATE INTO " . DB_PREFIX . "customer_online SET ip = '" . $this->db->escape($ip) . "', customer_id = '" . (int)$customer_id . "', url = '" . $this->db->escape($url) . "', referer = '" . $this->db->escape($referer) . "', date_added = '" . $this->db->escape(date('Y-m-d H:i:s')) . "'");
change to

Code: Select all

$this->db->query("INSERT INTO " . DB_PREFIX . "customer_online SET ip = '" . $this->db->escape($ip) . "', customer_id = '" . (int)$customer_id . "', url = '" . $this->db->escape($url) . "', referer = '" . $this->db->escape($referer) . "', date_added = '" . $this->db->escape(date('Y-m-d H:i:s')) . "'");

Opencart Developer - For custom work and support contact @ webcorvo@gmail.com


User avatar
Active Member

Posts

Joined
Mon Mar 20, 2017 11:42 pm
Location - Lisbon, Portugal

Post by harrye@karoola.net » Fri Sep 13, 2019 3:54 am

Hi,
Although this solution provides a nice tracking history for an on-line shopper, it does not address the display count in the "Dashboard" display of "People On-Line". This display now shows an incremental count of the entries from the table "oc_customer_on-line". Where would we edit the code to filter the IP address of the on-line users to count and show just the unique IP address of the shoppers?

Having the history in the database table is great but to see this value in the dashboard display just increment is incorrect because it does not reflect how many people are actually on-line.

Many thanks.
HarryE.


Posts

Joined
Fri Aug 30, 2019 6:29 am

Post by harrye@karoola.net » Fri Sep 13, 2019 4:33 am

After thinking about this a bit it would be useful to have in the "Dashboard - People On-Line Panel" two counters and a timestamp of the most recent access:

1. The unique count of customers who have visited the store (I say this because this modification now records the history of all users activity)
2. The total number of records in the oc_customer_online table
3. Last access timestamp (to see how long it's been since the last access)
4. Maybe also a display of the current timestamp with a lapsed time difference so we don't have to manually calculate the difference???

Cheers,
HarryE.
===


Posts

Joined
Fri Aug 30, 2019 6:29 am
Who is online

Users browsing this forum: No registered users and 7 guests