Error- Object reference not set to an instance of an object - When Open Cart page.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hello,

Check Attached image.

https://ibb.co/kmPHE5

GetAllDiscountsForCaching() Returns Null So we can't use there property. Its returning Object reference not set to an instance of an object.

Thanks,
Jatin
6 years ago
I solved by handled condition

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

if(discount != null)
{
   model.DiscountBox.AppliedDiscountsWithCodes.Add(new ShoppingCartModel.DiscountBoxModel.DiscountInfoModel()
   {
      Id = discount.Id,
      CouponCode = discount.CouponCode
   });
}
6 years ago
Thanks a lot! Already reported and fixed
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.