Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a returning customer has entered a couponcode which no longer exists accessing, the cart can cause a crash #2312

Closed
AndreiMaz opened this issue Apr 20, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@AndreiMaz
Copy link
Member

AndreiMaz commented Apr 20, 2017

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.

Source: http://www.nopcommerce.com/boards/t/47053/missing-null-check-causes-crash-in-cart.aspx

@AndreiMaz AndreiMaz added the bug label Apr 20, 2017
@AndreiMaz AndreiMaz added this to the Version 4.00 milestone Apr 20, 2017
AndreiMaz added a commit that referenced this issue May 8, 2017
…r exists accessing, the cart can cause a crash
@AndreiMaz AndreiMaz self-assigned this May 8, 2017
RomanovM pushed a commit that referenced this issue Jun 2, 2017
…r exists accessing, the cart can cause a crash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant