Following up with this issue:
we have disabled the Checkout as Guest feature - we have found that in some cases (8 orders out of 400) this issue also causes a mix up after payment. The order didn't get confirmed paid in nop so an email from the payment providers was received by the store manager, but not from nop, then the order had to be traced manually via the email address recieved from the payment provider and the order items are always in their "ShoppingCartItems"
disabling checkout as guest has stopped the order problem - I cleaned up all the extra guest roles and remapped the customers, but there are a number (about 20) of guest roles that have been created since.
obviously with the payment confirmation problem this issue became a problem for us - it's mangable now, but the guests role keep getting created and we are not sure why.
@a.m "I cannot reproduce it. I presume you customized the solution some wrong way because it works just fine out of the box."
Is there anyway of hinting as to what may be doing this - I have a plugin that has an ActionFilterAttribute and FilterProvider, which I believe are as MVC standard so I don't understand how I can resolve this problem - If it is something to do with the plugin then obviously I will change it, but I can't understand what is wrong yet.
In the ActionFilterAttribute I have a category that is hidden from the search unless a user has the "WebShop" role. This "WebShop" role is added on the fly to any user who hits a category that as "WebShop" as it's parent category directly so that all the webshop products become available in their search "session"
if (actionName.Contains("Category") && filterContext.HttpContext.Request.HttpMethod == "GET")
{
try
{
int _categoryId = (int)filterContext.ActionParameters["categoryId"];
var username = filterContext.HttpContext.User.Identity.Name;
var _categoryRepository = EngineContext.Current.Resolve<IRepository<Category>>();
var webshops = _categoryRepository.Table.SingleOrDefault(x => x.Name == "Webshops");
if (webshops != null)
{
var _category = _categoryRepository.Table.SingleOrDefault(x => x.Id == _categoryId);
if (_category.ParentCategoryId == webshops.Id)
{
var _customerService = EngineContext.Current.Resolve<ICustomerService>();
var _workContext = EngineContext.Current.Resolve<IWorkContext>();
var guestRole = _customerService.GetCustomerRoleBySystemName("WebshopUser");
var _customer = _workContext.CurrentCustomer;
_customer.CustomerRoles.Add(guestRole);
}
}
}
catch
{
//currentCategoryId ???? 0 ????
}
}
In my Filter Provider I'm intercepting Form POSTS - I have a data entity called "ListModule" that has a tab added to the product/edit - when the product is saved the action filter runs a routine on the received form data and saves the record to the database.
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Mvc;
using System.Data.Entity;
using Nop.Data;
using Nop.Core.Domain.Seo;
using System.Linq;
using Nop.Core.Infrastructure;
namespace Nop.Plugin.Misc.ContentModules.FilterProvider
{
class POSTProvider : IFilterProvider
{
private readonly IDbContext _dbContext;
private readonly IActionFilter _actionFilter;
private readonly IListModuleService _listmoduleService;
public POSTProvider(IDbContext dbContext, IActionFilter actionFilter, IListModuleService listmoduleService)
{
this._dbContext = dbContext;
this._actionFilter = actionFilter;
}
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
//List Module Product Data for Edit Product
if (actionDescriptor.ControllerDescriptor.ControllerType == typeof(Nop.Admin.Controllers.ProductController) && actionDescriptor.ActionName.Equals("Edit") && controllerContext.HttpContext.Request.HttpMethod == "POST")
{
NameValueCollection form = controllerContext.HttpContext.Request.Unvalidated.Form;
var _listmoduleService = EngineContext.Current.Resolve<IListModuleService>();
if (form["ListModuleId"] != null)
{
_listmoduleService.UpdateRecord(null, form);
}
}
return new Filter[]
{
new Filter(_actionFilter, FilterScope.Action, null)
};
}
}
}
the _listmoduleService.UpdateRecord parses the form data to update the record.
This system has worked since 3.1 - can anyone assist with this problem?
Thanks.