how to add count visitor on my website

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 yıl önce
I'm using Nopcommerce with source code right now
I want to implement the code about count visitor for my E-Commerce website but I'm stunned on how to retrieve data from the SQL server to implement code on my project. I know I need to customize in Customer table from database but I don't know how to implement the code to get the result in the picture below.

http://ibb.co/iBa31a
6 yıl önce
Hello Boonbunny,

Please refer code of online customer list on admin side,

Refer this link for some idea,

http://admin-demo.nopcommerce.com/Admin/OnlineCustomer/List

Now let me know if you need any help from my side.

Thanks,
6 yıl önce
for the next step.
I want to do coding for my project. But I don't know where the ado or entity for connecting through the database.
Now, I have a query for filtering the online users. Could you help me to do coding and connect the database on my project. The code is too complex for me.

http://ibb.co/kbPkWa
6 yıl önce
Hello

Please check your PM.

Thanks,
6 yıl önce
Hello Boonbunny,

Please try below code into footer.cshtml page.


Add below references

@using Nop.Services.Customers;
@using Nop.Core.Domain.Customers;


--------------------------------------------------

<div>
    @{
      var onlineCustomerMinutes = EngineContext.Current.Resolve<CustomerSettings>().OnlineCustomerMinutes;

      var onLineCustomer = EngineContext.Current.Resolve<ICustomerService>().GetOnlineCustomers(DateTime.UtcNow.AddMinutes(-onlineCustomerMinutes),
        null).Count();

      var getcustomerLastweek = EngineContext.Current.Resolve<ICustomerService>().GetAllCustomers(DateTime.UtcNow, DateTime.UtcNow.AddDays(-7)).Count();
      var getAllcustomer = EngineContext.Current.Resolve<ICustomerService>().GetAllCustomers().Count();


      <h3>Online : @onLineCustomer | This week : @getcustomerLastweek | Total : @getAllcustomer</h3>
    }
  </div>



Let me know if you want any other help.

Thanks,
3 yıl önce
hi

why last week always show 0 ???
3 yıl önce
The method declaration is
GetAllCustomers(DateTime? createdFromUtc = null, DateTime? createdToUtc = null,...

I.e.  I'd think the call should have the date params reversed:
var getcustomerLastweek = EngineContext.Current.Resolve<ICustomerService>().GetAllCustomers(DateTime.UtcNow.AddDays(-7), DateTime.UtcNow).Count();


P.S.
It would be best to just resolve ICustomerService once - e.g.

var customerService = EngineContext.Current.Resolve<ICustomerService>();
...
var onLineCustomer = customerService.GetOnlineCustomers(DateTime.UtcNow.AddMinutes(-onlineCustomerMinutes),null).Count();
var getcustomerLastweek = customerService.GetAllCustomers(DateTime.UtcNow, DateTime.UtcNow.AddDays(-7)).Count();
var getAllcustomer = customerService.GetAllCustomers().Count();
3 yıl önce
how to add total number of customers on home page?
3 yıl önce
how to add total number of customers on home page?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.