Sitefinity V7.3 Error Placing Order During Checkout - Object reference not set ...
I am having issues with ecommerce checkout and have the following error
"Object reference not set to an instance of an object."
Any ideas how to proceed.
Unfortunately the error message does not provide sufficient information in order to say what is causing the issue. Can you please delete the files under the ~/App_Data/Sitefinity/Logs folder (or copy the files to another location for backup) and then try to reproduce the issue. After that please check if there are any log files under the Logs folder and send the files to me to inspect them. The files may contain details about the issue and the cause for it.
In addition to this, can you please provide more details about the ecommerce on your side? Do you use the default functionality of Sitefinity or you have some custom implementations on your side - e.g. custom shipping provider, custom payment provider, custom checkout or any other customizations and etc.
I have a custom shipping provider because my company ships out of several warehouses. I tested using your built in UPS Ground provider and Offline Payment (cash), and it works correctly.
As for the error log there are a lot of File does not exist errors, which I assume are unrelated:
Stack Trace : at System.Web.StaticFileHandler.ProcessRequestForNonMapPathBasedVirtualFile(HttpRequest request, HttpResponse response, String overrideVirtualPath)
Here is a snippet from IShippingCarrierProvider..
public ShippingResponseContext GetServiceRates(IShippingRequest shippingData)
_shippingData = shippingData;
ShippingManager manager = new ShippingManager();
_carrierSettings = manager.GetShippingCarrierSetting(Name);
if (_carrierSettings == null)
throw new ArgumentException("Custom Shipping Provider settings not found");
double totalWeight = 0;
decimal total = 0;
List<string> listSkus = new List<string>();
foreach (var detail in shippingData.CartOrder.Details)
total += detail.Price;
if (detail.IsShippable == true)
double weight = (int)Math.Ceiling(detail.Weight * detail.Quantity);
totalWeight += weight;
Entities.ShoppingCart oShoppingCart = new Entities.ShoppingCart();
Business.ProductBusiness bProduct = new Business.ProductBusiness();
List<Entities.Product> oProducts = new List<Entities.Product>();
string rawSkus = listSkus.ToArray();
oProducts = bProduct.GetBySku(rawSkus).OrderBy(p => p.OutOfStockFlagId).ToList();
List<Entities.ShoppingCartAsAggregate> cartProductsAsAggregate = new List<Entities.ShoppingCartAsAggregate>();
foreach (Entities.Product product in oProducts)
ShoppingCarts.Objects.ShoppingCartAsAggregate aggregateItem = new Entities.ShoppingCartAsAggregate();
aggregateItem.Sku = product.Sku;
aggregateItem.Quantity = rawSkus.Where(s => s == product.Sku).Count();
aggregateItem.ProductId = product.ProductId;
aggregateItem.Price = product.Price;
aggregateItem.Title = product.Title;
aggregateItem.Total = string.Format("0:C", product.Price * aggregateItem.Quantity);
aggregateItem.DefaultShippingPrice = product.DefaultShippingPrice;
aggregateItem.CompanyId = product.CompanyId;
aggregateItem.Weight = product.Weight;
aggregateItem.WarehouseId = product.WarehouseId;
aggregateItem.OutOfStockFlagId = product.OutOfStockFlagId;
oShoppingCart.AggregateProducts = cartProductsAsAggregate;
oShoppingCart.Products = oProducts; // contains the distinct products in order to calculate the shipping
Business.ShoppingCartBusiness bShoppingCart = new Business.ShoppingCartBusiness();
double shippingCostOnly = 0, taxCostOnly = 0;
var ConfigurableItem = new Entities.ConfigurableItem();
ConfigurableItem.ShippingProviderCode = "UPS";
ConfigurableItem.DefaultWarehouseName = "BRINKMANN - ATHENS - SLOC:E";
oShoppingCart.ShippingAddressId = (new Brinkmann.OrderProcessing.BrinkmannOrders()).CreateAddress(
1, shippingData.CartOrder.Addresses.Address, shippingData.CartOrder.Addresses.Address2,
double subTotal = bShoppingCart.CalculateCartSubTotal(oShoppingCart, out shippingCostOnly, out taxCostOnly, ConfigurableItem);
oShoppingCart.ShippingCost = (decimal)shippingCostOnly;
ShippingResponseContext shippingResponseContext = new ShippingResponseContext();
shippingResponseContext.ShippingResponses = new System.Collections.Generic.List<IShippingResponse>();
GenericShippingResponse shippingResponse = new GenericShippingResponse();
shippingResponse.ServiceCode = "CUSTOM"; // e.g "FIRSTCLASS", "OVERNIGHT", "2DAY"
shippingResponse.ServiceName = "Custom"; // full name of the service "First Class", "Overnight", "Two Day Mail".
shippingResponse.ShippingCarrierName = "Custom"; // Carrier name (e.g. "UPS", "FEDEX", "USPS")
shippingResponse.ShippingServiceName = "custom";
shippingResponse.SortOrder = 1; // (optional) Display sort order (1,2,3...)
shippingResponse.ServicePrice = (decimal)shippingCostOnly; // Cost of the service (service's price)
Sorry for the formatting, I cannot upload text attachments.
It is really hard to say what is causing this null reference exception since there are no any error logs and a stack trace to show where exactly the issue occurs. As you have also noted, the error messages related to files which does not exists seems not to be related to this issue.
Since the checkout works properly when using the built-in shipping provider it seems that the issue is caused by your custom implementation of the shipping provider. Is it an for you to run the project in debug mode and check where the exception occurs in your custom shipping provider?
What I can also suggest is to delete the error log files under ~/App_Data/Sitefinity/Logs folder (or copy them to another location for backup) and then please try to reproduce the issue again. Then please check if there are any error log files generated under the Logs folder. If yes, please send me the files in order to inspect them. This way we can make sure that the error messages are related to the exact issue and it will be easier to inspect them.
In addition to this, based on our experience the Object reference not set to an instance of an object can occur if Sitefinity is not able to find the shipping settings which are supported by the custom shipping provider. You can also review these settings on your side.
In addition to this, you can also checkout the following sample we have provided in our documentation article for creating custom shipping provider:
I went through the steps in creating a custom shipping carrier provider. The code snippet is from the link you provided in the preceding post. Anyway I have revisited the logs and here is the trace:
Timestamp: 7/9/2015 9:45:42 PM
Message: System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Sitefinity.Modules.Ecommerce.Orders.Business.CartOrderShippingValidator.ValidateShipping(CartOrder cartOrder)
at Telerik.Sitefinity.Modules.Ecommerce.Orders.Business.OrderValidator.Validate(CartOrder cartOrder)
at Telerik.Sitefinity.Modules.Ecommerce.Orders.Business.OrderCheckout.Checkout(Guid cartOrderId, CheckoutState checkoutState, Customer customer)
at Telerik.Sitefinity.Modules.Ecommerce.Orders.OrdersManager.Checkout(Guid cartOrderId, CheckoutState checkoutState, Customer customer)
App Domain: 52f2f834-2-130809517294119774
Process Name: C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe
The shipping carrier provider is working as I have been debugging the whole time. However, it is bombing out in your validator but I have no idea what object is missing.
I figured it out. Service Code was not set properly.