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

UPS and ShipStation plugins break cart #5554

Closed
Ochapparel opened this issue Mar 19, 2021 · 7 comments
Closed

UPS and ShipStation plugins break cart #5554

Ochapparel opened this issue Mar 19, 2021 · 7 comments
Assignees
Labels

Comments

@Ochapparel
Copy link

Ochapparel commented Mar 19, 2021

nopCommerce version:
4.40.1

Steps to reproduce the problem:

  1. Install UPS Plugin

  2. Configure it to get rates

  3. Enable Only UPS (turn others off) (/Admin/Shipping/Providers)
    image

  4. Add an item to your cart that requires shipping

  5. Go to Cart

Get the below error:
image

The UPS Version of GetFixedRateAsync returns null and causes the error (public class UPSComputationMethod)
image


When I turn "Manual (Fixed or By Weight and By Total)" on the error goes away:
image

image

This was tested on a 4.40.1 download on 3/16

@AndreiMaz
Copy link
Member

@Ochapparel please share the detailed log error (admin area > system > log)

@Ochapparel
Copy link
Author

@AndreiMaz

Log level
Error

Short message
Object reference not set to an instance of an object.

Full message
System.NullReferenceException: Object reference not set to an instance of an object.
at Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotalAsync(IList1 cart, Boolean includingTax) in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Libraries\Nop.Services\Orders\OrderTotalCalculationService.cs:line 1101 at Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotalAsync(IList1 cart) in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Libraries\Nop.Services\Orders\OrderTotalCalculationService.cs:line 1044
at Nop.Web.Factories.ShoppingCartModelFactory.PrepareOrderTotalsModelAsync(IList1 cart, Boolean isEditable) in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Presentation\Nop.Web\Factories\ShoppingCartModelFactory.cs:line 1136 at Nop.Web.Components.OrderTotalsViewComponent.InvokeAsync(Boolean isEditable) in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Presentation\Nop.Web\Components\OrderTotals.cs:line 34 at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsyncCore(ObjectMethodExecutor executor, ViewComponentContext context) at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsync(ViewComponentContext context) at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentHelper.InvokeCoreAsync(ViewComponentDescriptor descriptor, Object arguments) at AspNetCore.Views_Shared_Components_OrderSummary_Default.<ExecuteAsync>b__14_0() in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Presentation\Nop.Web\Views\Shared\Components\OrderSummary\Default.cshtml:line 255 at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.GetChildContentAsync(Boolean useCachedResult, HtmlEncoder encoder) at Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count) at AspNetCore.Views_Shared_Components_OrderSummary_Default.ExecuteAsync() in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Presentation\Nop.Web\Views\Shared\Components\OrderSummary\Default.cshtml:line 23 at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) at Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult.ExecuteAsync(ViewComponentContext context) at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsync(ViewComponentContext context) at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentHelper.InvokeCoreAsync(ViewComponentDescriptor descriptor, Object arguments) at AspNetCore.Views_ShoppingCart_Cart.ExecuteAsync() in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Presentation\Nop.Web\Views\ShoppingCart\Cart.cshtml:line 19 at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at WebMarkupMin.AspNetCore5.WebMarkupMinMiddleware.ProcessAsync(HttpContext context, Boolean useMinification, Boolean useCompression)
at WebMarkupMin.AspNetCore5.WebMarkupMinMiddleware.ProcessAsync(HttpContext context, Boolean useMinification, Boolean useCompression)
at WebMarkupMin.AspNetCore5.WebMarkupMinMiddlewareBase.Invoke(HttpContext context)
at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 125
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Nop.Services.Authentication.AuthenticationMiddleware.InvokeAsync(HttpContext context) in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Libraries\Nop.Services\Authentication\AuthenticationMiddleware.cs:line 94
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Nop.Services.Installation.InstallUrlMiddleware.InvokeAsync(HttpContext context, IWebHelper webHelper) in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Libraries\Nop.Services\Installation\InstallUrlMiddleware.cs:line 52
at Nop.Services.Common.KeepAliveMiddleware.InvokeAsync(HttpContext context, IWebHelper webHelper) in C:\Users\dootc\Documents\Visual Studio 2019\Websites\4.40_fresh\Libraries\Nop.Services\Common\KeepAliveMiddleware.cs:line 49
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

IP address
127.0.0.1

Customer
test@ochapparel.com

Page URL
http://localhost:15536/cart

Referrer URL
http://localhost:15536/

Created on
3/19/2021 7:56:38 PM

@noptools
Copy link

The code fix for this is that GetFixedRateAsync needs to return a Task with result null:

return Task.FromResult<decimal?>(null);

(Alternately, one could make the method async, but in this case there's no point incurring the async wrapper overhead, and you'd also get warning “This async method lacks 'await' operators and will run synchronously”)

This is not limited to the UPS plugin; the ShipStation plugin has the same problem.

@noptools
Copy link

I note that Andrei added this to the Version 4.50 milestone, but I suspect it really should be done in a minor release (e.g. 4.40.2 ;)

@Ochapparel
Copy link
Author

Agreed, this is a big thing and couldn't wait for a whole release cycle.

@AndreiMaz please consider a 4.40.2 release

@noptools I'll update it locally so i can continue using 4.40

@AndreiMaz AndreiMaz changed the title Plugin Shipping.UPS GetFixedRateAsync Returns Null - Breaks Cart UPS and ShipStation plugins break cart Mar 22, 2021
@skoshelev
Copy link
Contributor

Closed #5554

@Ochapparel
Copy link
Author

@AndreiMaz @skoshelev thanks for the minor release.

amzr0987 pushed a commit to amzr0987/nopCommerce that referenced this issue Mar 30, 2021
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

4 participants