Skip to content

Commit

Permalink
#2312 If a returning customer has entered a couponcode which no longe…
Browse files Browse the repository at this point in the history
…r exists accessing, the cart can cause a crash
  • Loading branch information
AndreiMaz committed May 8, 2017
1 parent 379d8ac commit b5f7884
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Presentation/Nop.Web/Factories/ShoppingCartModelFactory.cs
Expand Up @@ -818,11 +818,14 @@ public virtual PictureModel PrepareCartItemPictureModel(ShoppingCartItem sci, in
var discount = _discountService.GetAllDiscountsForCaching(couponCode: couponCode)
.FirstOrDefault(d => d.RequiresCouponCode && _discountService.ValidateDiscount(d, _workContext.CurrentCustomer).IsValid);

model.DiscountBox.AppliedDiscountsWithCodes.Add(new ShoppingCartModel.DiscountBoxModel.DiscountInfoModel()
if (discount != null)
{
Id = discount.Id,
CouponCode = discount.CouponCode
});
model.DiscountBox.AppliedDiscountsWithCodes.Add(new ShoppingCartModel.DiscountBoxModel.DiscountInfoModel()
{
Id = discount.Id,
CouponCode = discount.CouponCode
});
}
}
model.GiftCardBox.Display = _shoppingCartSettings.ShowGiftCardBox;

Expand Down

0 comments on commit b5f7884

Please sign in to comment.