Missing Null check causes crash in cart

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 7 años
If a returning customer has entered a couponcode which no longer exists accessing, the cart can cause a crash due to the following lines in ShoppingCartModelFactory:


var discount = _discountService.GetAllDiscountsForCaching(couponCode: couponCode)
                    .FirstOrDefault(d => d.RequiresCouponCode && _discountService.ValidateDiscount(d, _workContext.CurrentCustomer).IsValid);

                model.DiscountBox.AppliedDiscountsWithCodes.Add(new ShoppingCartModel.DiscountBoxModel.DiscountInfoModel()
                {
                    Id = discount.Id,
                    CouponCode = discount.CouponCode
                });


The discount in this case is null.
Hace 7 años
Thanks a lot for reporting. You're right. I've just created a work item
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.