我有自定义结帐方法。我也有自定义送货方式。
我已将所有自定义代码翻录出来并直接复制并粘贴Sitefinity文档中的自定义送货方式文件:
和
http://www.sitefinity.com/documentation/documentationarticles/shipping-provider-model
根据此文档,我可以在电子商务后端创建新的送货方式,并选择我的自定义送货方式。
我有以下代码将我的结帐状态送货方式ID设置为我的自定义送货方式ID。我的购物车订单也一样:
CheckoutState checkoutState = new CheckoutState()
{
...
ShippingMethodId = shippingManager.GetShippingMethods().FirstOrDefault(s => s.Name == "custom-shipping").Id,
ShippingMethodName = shippingManager.GetShippingMethods().FirstOrDefault(s => s.Name == "custom-shipping").Name,
...
}
和
cartOrder.ShippingMethodId = shippingManager.GetShippingMethods().FirstOrDefault(s => s.Name == "custom-shipping").Id;
工作正常,花花公子。获取送货方式。此送货方式包含我在遵循文档时定义的自定义送货运单ID。我添加了2个运输服务设置。我也可以使用以下方法查询它们:
var shippingCarrierInfo = shippingManager.GetShippingCarrierSetting("custom-shipping");
List<ShippingServiceSettings> services = shippingManager.GetShippingServiceSettings().Where(
x => x.ShippingCarrierName == shippingCarrierInfo.Name &&
x.IsActive == true).ToList();
我没有空或空或任何东西。所有信息均符合预期。
我通过这样做来获取我的服务的运费回复:
List<IShippingResponse> shippingResponses = processShipping.GetApplicableShippingMethods(checkoutState, cartOrder).ToList();
这会抛出一条可爱的通用错误消息:
空参考例外 {&#34;对象引用未设置为对象的实例。&#34;}
当然,我无法看到他们所说的是空的。但是我得到了一个错误的方法的堆栈跟踪。
迹:
at Telerik.Sitefinity.Modules.Ecommerce.Shipping.ShippingManager.GetShippingCarrierProvider(Guid shippingMethodId)
at Telerik.Sitefinity.Modules.Ecommerce.Shipping.Business.OnlineShippingMethodRetriever.GetApplicableShippingMethods(CheckoutState checkoutState, CartOrder cartOrder)
at Telerik.Sitefinity.Modules.Ecommerce.BusinessServices.Shipping.Implementations.EcommerceShippingMethodService.GetApplicableShippingMethods(CheckoutState checkoutState, CartOrder cartOrder)
at SitefinityWebApp.Mvc.Controllers.CheckoutController.RunCheckout(CheckoutForm CheckoutForm, User user, SitefinityProfile profile, CartOrder cartOrder, String paymentMethod) in c:\clients\badder ruter\RiverValleyDairySF\RiverValleyDairy\Mvc\Controllers\CheckoutController.cs:line 600
at SitefinityWebApp.Mvc.Controllers.CheckoutController.ProcessPayment(CheckoutForm CheckoutForm) in c:\clients\badder ruter\RiverValleyDairySF\RiverValleyDairy\Mvc\Controllers\CheckoutController.cs:line 210
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()
我失去了我需要做的事情。这是一个来回的支持票,现在约3.5个星期。愤怒的客户和我需要找到一种方法来实现这一点。就像我直接从文档中复制和粘贴说的那样。有人有这方面的经验吗?