Discount Bug on Service Layer

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
When i define several requirement in several groups for a discount some of them did not work.
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);
4 years ago
msn4561 wrote:
When i define several requirement in several groups for a discount some of them did not work.


What exactly doesn't work? Could you please provide a list of steps to reproduce the error.
4 years ago
Hi,
i found the problem,in my code GetAllDiscountRequirements method was override by a plugin and return all requirements instead of parent.
sorry i forgot to mention that here.

😱😱😱😨😨😨
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.