how to stop guest customers creation in database ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
how to stop guest customers creation in database ?

I made a website live 2 weeks back and within 2 week I see 3000 guest customers in the database that I just deleted in Maintenance.

Is it possible to stop these automatic created guest customers ? what is the use ? they keep on using database and ID keep on adding in table, what if one day it reaches the maximum value ? if this is the speed i think it is possible even thought the max limit is -2147483648 to 2147483647.

Guest customers in nopcommerce are being created very fast, in 2 week the ID has reached 3140
11 years ago
It's by design.  You can search the forums about it.  Here are a couple
https://www.nopcommerce.com/boards/t/11434/sql-guest-users.aspx
https://www.nopcommerce.com/boards/t/15564/customerid-jumps-from-1-to-591-for-only-8-registred-users.aspx?p=1
7 years ago
if you interested to do some customization you can refer below as well
https://www.nopcommerce.com/boards/t/37816/suggestion-improvement-on-generating-guest-customer.aspx
3 years ago
This is my solution, I was able to limit the new guest account, each IP accessing the website will be created as 1 new guest account.
In this case, you can Disable the DeleteGuests task as it will no longer be needed.

Open the file at the path: Nopcommerce\Libraries\Nop.Services\Customers\CustomerService.cs
and add the following line of code:

public virtual Customer InsertGuestCustomer()
        {
            //KEVIN NGUYEN - get current IP address
            var currentIpAddress = EngineContext.Current.Resolve<IWebHelper>().GetCurrentIpAddress();
            if (CommonHelper.IsValidIpAddress(currentIpAddress))
            {
                var guest = _customerRepository.Table.Where(x => x.LastIpAddress == currentIpAddress
                                                    && (x.Username == null || x.Username == string.Empty)
                                                    && (x.Email == null || x.Email == string.Empty)
                                                    && !x.IsSystemAccount)?.FirstOrDefault();
                if (guest != null)
                    return guest;
            }

            var customer = new Customer
            {
                CustomerGuid = Guid.NewGuid(),
                Active = true,
                CreatedOnUtc = DateTime.UtcNow,
                LastActivityDateUtc = DateTime.UtcNow,
                LastIpAddress = currentIpAddress
            };

            //add to 'Guests' role
            var guestRole = GetCustomerRoleBySystemName(NopCustomerDefaults.GuestsRoleName);
            if (guestRole == null)
                throw new NopException("'Guests' role could not be loaded");

            _customerRepository.Insert(customer);

            AddCustomerRoleMapping(new CustomerCustomerRoleMapping { CustomerId = customer.Id, CustomerRoleId = guestRole.Id });

            return customer;
        }


2 years ago
It is by design. Nopcommerce creates guest customers for new session for the sake of saving cart/orders info. There's a built in scheduled task Delete guests  in /Admin/ScheduleTask/List so you don't have to manually delete them.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.