بسته

خطای Object reference not set to an instance of an object

6 سال پیش
#1023 نقل قول
هنگام رفتن به سبد خرید خطای زیر ایجاد می شود. ابتدا فکر می کردم بخاطر تم است. بعد از بررسی متوجه شدم خطا مربوط به خود ناپ کامرس است. من از ناپ کامرس نسخه 3.9 استفاده می کنم.

پیام خطا:

Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   Nop.Web.Factories.ShoppingCartModelFactory.PrepareShoppingCartModel(ShoppingCartModel model, IList`1 cart, Boolean isEditable, Boolean validateCheckoutAttributes, Boolean prepareEstimateShippingIfEnabled, Boolean setEstimateShippingDefaultAddress, Boolean prepareAndDisplayOrderReviewData) +932
   Nop.Web.Controllers.ShoppingCartController.Cart() +240

2
6 سال پیش
#1025 نقل قول
شما ظاهرا از نسخه اولیه 3.9 که منتشر شده بود استفاده می کنید. این خطا بعدا سریعا شناسایی و رفع شد. شما می تونید نسخه جدیدتر آنرا دانلود و در هاست جایگزین کنید.
دانلود ناپ کامرس 3.90

تنها فایلی که نیاز است جایگزین کنید فایل nop.web.dll در پوشه bin است.


کدی که تغییر یافته:
src/Presentation/Nop.Web/Factories/ShoppingCartModelFactory.cs


                 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;

3
دسته بندی ها