I review the code and noticed that in DiscountService.cs we have some issue.
If i didn't miss anything, topLevelGroup must be set as first parameter for GetValidationResult() not requirementsForCaching.
Can anyone approve this?
original code:
//discount requirements
var key = string.Format(NopDiscountDefaults.DiscountRequirementModelCacheKey, discount.Id);
var requirementsForCaching = _cacheManager.Get(key, () =>
{
var requirements = GetAllDiscountRequirements(discount.Id, true);
return GetReqirementsForCaching(requirements);
});
//get top-level group
var topLevelGroup = requirementsForCaching.FirstOrDefault();
if (topLevelGroup == null || (topLevelGroup.IsGroup && !topLevelGroup.ChildRequirements.Any()) || !topLevelGroup.InteractionType.HasValue)
{
//there are no requirements, so discount is valid
result.IsValid = true;
return result;
}
//requirements exist, let's check them
var errors = new List<string>();
result.IsValid = GetValidationResult(requirementsForCaching, topLevelGroup.InteractionType.Value, customer, errors);