Error executing template "Designs/Plus/_parsed/Dw_AddToBasketOverlayOwnTemplate.parsed.cshtml"System.NullReferenceException: Objektreferencen er ikke indstillet til en forekomst af et objekt.ved CompiledRazorTemplates.Dynamic.RazorEngine_2c50df4ba5a24b11bce02e511e8d0419.Execute() i C:\inetpub\wwwroot\plus-live\Files\Templates\Designs\Plus\_parsed\Dw_AddToBasketOverlayOwnTemplate.parsed.cshtml:linje 17ved RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)ved RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)ved RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)ved RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)ved Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @using Dynamicweb.Ecommerce.Orders 2 @using Dynamicweb.Ecommerce.Common 3 @using Dynamicweb.Ecommerce 4 @using System.Web; 5 @using Plus.CustomModules.AddMultipleProducts; 6 @using Dynamicweb.Security.UserManagement; 7 @using Dynamicweb.Security.UserManagement.Common.CustomFields; 8 @using Dynamicweb.Core; 9 10 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 11 12 @{ 13 string basketLink = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("default.aspx?id=" + GetString("Item.Area.CartPageId")); 14 string hidePrices = Pageview.Area.Item["Hide_Prices"].ToString(); 15 16 17 var prods = HttpContext.Current.Request.QueryString["products"].Split(',').ToList(); 18 var quantities = HttpContext.Current.Request.QueryString["quantities"].Split(',').ToList(); 19 20 // Evaldas: This template is no longer responsible for adding cart items, thus the following line has been removed: 21 // MultiAdd.Addmulti(prods, quantities); 22 23 24 //Order cart; 25 //if (Dynamicweb.Ecommerce.Common.Context.Cart != null) 26 //{ 27 // cart = Dynamicweb.Ecommerce.Common.Context.Cart; 28 //} 29 //else 30 //{ 31 // cart = new Order(); 32 // Dynamicweb.Ecommerce.Common.Context.SetCart(cart); 33 //} 34 35 //for (int i = 0; i < prods.Count; i++) 36 //{ 37 // var builderConfig = new OrderLineBuilderConfig { ProductId = prods[i], Quantity = double.Parse(quantities[i]), AddToCart = true }; 38 // cart.OrderLineBuilder(builderConfig); 39 // cart.CalculateDiscounts(); 40 // cart.Save(); 41 42 //} 43 double totalAddedPrice = 0; 44 45 var builder = new UriBuilder(HttpContext.Current.Request.Url); 46 var query = HttpUtility.ParseQueryString(string.Empty); 47 48 double totalPriceWithDecimals = 0; 49 double productPriceWithDecimals = 0; 50 51 double frac = 0; 52 double frac2 = 0; 53 54 double fracPerUnit = 0; 55 double frac2PerUnit = 0; 56 57 var prodID = ""; 58 } 59 <!--Her skal være noget AJAX til at opdater kurv i header--> 60 61 62 <section class="overlay-products-added"> 63 <header class="overlay-products-added__header"> 64 <h3 class="heading heading--fw-element">@Translate("Følgende er tilføjet til indkøbslisten", "Følgende er tilføjet til indkøbslisten")</h3> 65 </header> 66 <table class="products-table"> 67 <thead> 68 <tr class="products-table__row products-table__row--head"> 69 <th class="products-table__cell products-table__cell--amount">@Translate("Antal", "Antal")</th> 70 <th class="products-table__cell products-table__cell--product">@Translate("Produkter", "Produkter")</th> 71 72 @if (hidePrices == "False") 73 { 74 <th class="products-table__cell products-table__cell--price">@Translate("Vejledende priser fra", "Vejledende priser fra")</th> 75 } 76 </tr> 77 </thead> 78 <tbody> 79 80 @for (int i = 0; i < prods.Count; i++) 81 { 82 var prod = Dynamicweb.Ecommerce.Products.Product.GetProductById(prods[i]); 83 84 prodID = prod.Id; 85 } 86 87 88 @foreach (LoopItem item in GetLoop("OrderLines").Where(x => x.GetString("Ecom:Order:OrderLine.ProductID") == prodID)) 89 { 90 91 92 bool inStock = item.GetDouble("Ecom:Product.Stock") > 0; 93 DateTime backOrderDate = item.GetDate("Ecom:Product:Field.ProductNextBackorderDate"); 94 bool hasBackOrderDate = backOrderDate != DateTime.MinValue; 95 bool hasBackOrderDateGTToday = backOrderDate > DateTime.Now; 96 97 totalAddedPrice += (item.GetDouble("Ecom:Order:OrderLine.UnitPrice.PriceWithoutVAT.Value") * double.Parse(quantities[0])); 98 totalPriceWithDecimals += Converter.ToDouble(item.GetString("Ecom:Product.Price.PriceWithoutVAT")); 99100 double totalPriceval = totalAddedPrice;101 frac += totalPriceval - Math.Truncate(totalPriceval);102 frac2 += Math.Round(frac, 2, MidpointRounding.AwayFromZero);103104105 double prodcuctPriceval = totalPriceWithDecimals;106 fracPerUnit += prodcuctPriceval - Math.Truncate(prodcuctPriceval);107 frac2PerUnit += Math.Round(fracPerUnit, 2, MidpointRounding.AwayFromZero);108109110 <tr class="products-table__row">111 <td class="products-table__cell products-table__cell--amount" data-header="Antal">@quantities[0] @Translate("stk.", "stk.")</td>112 <td class="products-table__cell products-table__cell--product">113 @item.GetString("Ecom:Order:OrderLine.ProductName")114115116 @if (!inStock)117 {118 if (hasBackOrderDateGTToday)119 {120 <br>121 <span class="item-number item-number--red item-number--product-detail">@Translate("Product back in stock with date", "Varen er ikke tilgælgelig før {BackInStockDate}").Replace("{BackInStockDate}", backOrderDate.ToString("dd-MM-yyyy"))</span>122 }123 else if (!hasBackOrderDate)124 {125 <br>126 <span class="item-number item-number--red item-number--product-detail">@Translate("Product back in stock", "Denne vare er PT ikke på lager")</span>127 }128 }129 </td>130131 @if (hidePrices == "False")132 {133 <td class="products-table__cell products-table__cell--price">134 <div class="price price--products-table">135 <span class="price__unit">@Translate("DKK", "DKK") </span>136137 @* With decimals *@138 @if (frac2PerUnit > 0)139 {140 <span class="price__price">@totalPriceWithDecimals.ToString("n")</span>141 }142143 @* Without decimals *@144 else145 {146 <span class="price__price">@totalPriceWithDecimals@Translate("PriceDelimitter", ".-")</span>147 }148149 </div>150 </td>151 }152 </tr>153 }154155 @if (hidePrices == "False")156 {157 <tr class="products-table__row products-table__row--sum">158 <td class="products-table__cell products-table__cell--sum" colspan="3">159 <div class="price price--products-table-sum">160 <div class="price__header">@Translate("I alt", "I alt") </div>161 <span class="price__unit">@Translate("DKK", "DKK") </span>162163 @* With decimals *@164 @if (frac2 > 0)165 {166 <span class="price__price">@totalAddedPrice.ToString("n")</span>167 }168169 @* Without decimals *@170 else171 {172 <span class="price__price">@totalAddedPrice@Translate("PriceDelimitter", ".-")</span>173 }174175 </div>176 </td>177 </tr>178 }179180181182 </tbody>183 </table>184 <div class="overlay-products-added__buttons">185 <a class="button button--overlay-products-added" href="@basketLink" title="" property="url">186 <span class="button__text">@Translate("Gå til indkøbslisten", "Gå til indkøbslisten")</span>187 </a>188 </div>189 <div id="content">@GetValue("DwContent(content)")</div>190 </section>191192193