public bool HasCustomerCookie()
{
if (_httpContext == null || _httpContext.Request == null)
return false;
var customerCookie = GetCustomerCookie();
if (customerCookie != null && !String.IsNullOrEmpty(customerCookie.Value))
return true;
else return false;
}
public Customer AddGuestCustomer()
{
var customer = _customerService.InsertGuestCustomer();
SetCustomerCookie(customer.CustomerGuid);
return customer;
}
Dont foget to add too in IWorkContext
bool HasCustomerCookie();
Customer AddGuestCustomer();
And finally change the methods public virtual IList <string> AddToCart (...)
after the line below
if (productVariant == null)
throw new ArgumentNullException("productVariant");
Add
if (_workContext.HasCustomerCookie() && customer.IsSearchEngineAccount())
{
var guestCutomer = _workContext.AddGuestCustomer();
if (guestCutomer != null)
customer = guestCutomer;
}