+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Sitefinity V7.3 Error Placing Order During Checkout - Object reference not set ...

Sitefinity V7.3 Error Placing Order During Checkout - Object reference not set ...

7 posts, 1 answered
  1. Ronn
    Ronn avatar
    6 posts
    Registered:
    16 May 2014
    30 Jun 2015
    Link to this post

    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.

    Ronn

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    08 Dec 2016
    03 Jul 2015
    Link to this post
    Hello Ronn,

    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.

    Regards,
    Sabrie Nedzhip
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Ronn
    Ronn avatar
    6 posts
    Registered:
    16 May 2014
    06 Jul 2015 in reply to Sabrie Nedzhip
    Link to this post

    Sabrie,

    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)

    Regards,

    Ronn

  4. Ronn
    Ronn avatar
    6 posts
    Registered:
    16 May 2014
    06 Jul 2015
    Link to this post

    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)
        {
            listSkus.Add(detail.Sku);
            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;
            cartProductsAsAggregate.Add(aggregateItem);
        }
        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[0].Address, shippingData.CartOrder.Addresses[0].Address2,
            shippingData.CartOrder.Addresses[0].City, shippingData.CartOrder.Addresses[0].StateRegion,
            shippingData.CartOrder.Addresses[0].PostalCode, shippingData.CartOrder.Addresses[0].Country,
            shippingData.CartOrder.Addresses[0].FirstName, shippingData.CartOrder.Addresses[0].LastName,
            "", shippingData.CartOrder.Addresses[0].Phone);
        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)
        shippingResponseContext.ShippingResponses.Add(shippingResponse);
        return shippingResponseContext;
    }

    Sorry for the formatting, I cannot upload text attachments.

  5. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    08 Dec 2016
    09 Jul 2015
    Link to this post
    Hi Ronn,

    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:

    http://docs.sitefinity.com/for-developers-create-a-custom-shipping-carrier-provider

    Regards,
    Sabrie Nedzhip
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  6. Ronn
    Ronn avatar
    6 posts
    Registered:
    16 May 2014
    09 Jul 2015 in reply to Sabrie Nedzhip
    Link to this post

    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)
       at Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI.CheckoutViews.Preview.Checkout()
    Category: ErrorLog
    Priority: -1
    EventId: 1
    Severity: Information
    Title:
    Machine: DALSOC001
    App Domain: 52f2f834-2-130809517294119774
    ProcessId: 5476
    Process Name: C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe
    Thread Name:
    Win32 ThreadId:1976
    Extended Properties:
    ----------------------------------------
    ---------------------------------------

     

    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.

  7. Ronn
    Ronn avatar
    6 posts
    Registered:
    16 May 2014
    10 Jul 2015
    Link to this post
    I figured it out. Service Code was not set properly.
    Answered
7 posts, 1 answered