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

Discount System.NullReferenceException in SubTotal in Shopping Cart x.xx #491

Closed
coffeepoweredcodemachine opened this issue Jun 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@coffeepoweredcodemachine

The SubTotal in Shopping Cart x.xx discount option throws a System.NullReferenceException when you attempt to use it. All other discount codes work as expected.

Reproduction:

  1. Marketing > Discounts
  2. Click the Add New button.
  3. Enter a name, set discount amount to 15, check requires coupon code.
  4. Click Save and Continue Edit.
  5. Click COUPON CODES, then ADD NEW RECORD.
  6. Enter a coupon code and then click SAVE.
  7. Click REQUIREMENTS. Under Add a new discount requirement choose 'SubTotal in Shopping Cart x.xx'.
  8. Set the required spend amount to anything. Click SAVE.
  9. Click Save. in the top right to save the discount.
  10. Go to your cart and try to use the code.

Expected Result:

Coupon is applied, or an error is shown.

Actual Result:

Nothing happens in the UI. Browser Console shows an exception being thrown.

Exception detail:

System.NullReferenceException: Object reference not set to an instance of an object.\n at DiscountRules.Standard.Providers.ShoppingCartDiscountRule.CheckRequirement(DiscountRuleValidationRequest request)\n at Grand.Business.Catalog.Services.Discounts.DiscountValidationService.ValidateDiscount(Discount discount, Customer customer, Store store, Currency currency, String[] couponCodesToValidate) in /home/web/grandnode/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountValidationService.cs:line 211\n at Grand.Web.Validators.ShoppingCart.DiscountCouponValidator.<>c__DisplayClass0_0.<<-ctor>b__2>d.MoveNext()\n--- End of stack trace from previous location ---\n at FluentValidation.DefaultValidatorExtensions.<>c__DisplayClass70_02.<<CustomAsync>b__0>d.MoveNext() in /_/src/FluentValidation/DefaultValidatorExtensions.cs:line 1150\n--- End of stack trace from previous location ---\n at FluentValidation.Internal.RuleComponent2.ValidateAsync(ValidationContext1 context, TProperty value, Boolean useAsync, CancellationToken cancellation) in /_/src/FluentValidation/Internal/RuleComponent.cs:line 71\n at FluentValidation.Internal.PropertyRule2.ValidateAsync(ValidationContext1 context, Boolean useAsync, CancellationToken cancellation) in /_/src/FluentValidation/Internal/PropertyRule.cs:line 156\n at FluentValidation.AbstractValidator1.ValidateInternalAsync(ValidationContext1 context, Boolean useAsync, CancellationToken cancellation) in /_/src/FluentValidation/AbstractValidator.cs:line 246\n at FluentValidation.AbstractValidator1.ValidateAsync(ValidationContext1 context, CancellationToken cancellation) in /_/src/FluentValidation/AbstractValidator.cs:line 220\n at Grand.Infrastructure.Validators.ValidationFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) in /home/web/grandnode/src/Core/Grand.Infrastructure/Validators/ValidationFilter.cs:line 53\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)\n at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)\n at Grand.Web.Common.Middleware.ContextLoggingMiddleware.InvokeAsync(HttpContext context) in /home/web/grandnode/src/Web/Grand.Web.Common/Middleware/ContextLoggingMiddleware.cs:line 34\n at Grand.Web.Common.Middleware.CultureSettingMiddleware.InvokeAsync(HttpContext context, IWorkContext workContext) in /home/web/grandnode/src/Web/Grand.Web.Common/Middleware/CultureSettingMiddleware.cs:line 32\n at Grand.Web.Common.Middleware.WorkContextMiddleware.InvokeAsync(HttpContext context, IWorkContextSetter workContext) in /home/web/grandnode/src/Web/Grand.Web.Common/Middleware/WorkContextMiddleware.cs:line 47\n at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\n at Grand.Web.Common.Middleware.PoweredByMiddleware.InvokeAsync(HttpContext context, IPoweredByMiddlewareOptions options) in /home/web/grandnode/src/Web/Grand.Web.Common/Middleware/PoweredByMiddleware.cs:line 23\n at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)\n at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)\n at Grand.Web.Common.Middleware.InstallUrlMiddleware.InvokeAsync(HttpContext context) in /home/web/grandnode/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs:line 46\n at Grand.Web.Common.Middleware.DbVersionCheckMiddleware.Invoke(HttpContext context, ICacheBase cacheBase, IRepository1 repository) in /home/web/grandnode/src/Web/Grand.Web.Common/Middleware/DbVersionCheckMiddleware.cs:line 37\n at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)\n at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)\n at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)\n at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)\n at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)\n at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

@KrzysztofPajak KrzysztofPajak added the bug Something isn't working label Jun 10, 2024
@KrzysztofPajak
Copy link
Member

@coffeepoweredcodemachine thanks for reporting, fixed #492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants