Shopping Cart

Error executing template "Designs/WordMusic/eCom7/CartV2/Step/shoppingCart.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_3252f037666a4a2892f8ebb4e883c3f5.Execute() in d:\Domains\Sites\qa-sweetums.dw-demo.com\Files\Templates\Designs\WordMusic\eCom7\CartV2\Step\shoppingCart.cshtml:line 505
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 2 @using System 3 @using System.Linq 4 @using Dynamicweb.Rendering; 5 @using Dynamicweb.Core 6 @using Dynamicweb.Frontend 7 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 8 @using System 9 @using System.Collections.Generic 10 @using System.IO 11 @using System.Linq 12 @using System.Web 13 @using Dna.UrlServices 14 @using Dynamicweb.Rendering 15 @using Dna.Validation 16 @using Dynamicweb.Core 17 @using Dna.ImageProcessing 18 @using Dna.Optimizer 19 @using Dynamicweb.Ecommerce.Products 20 @{ 21 @helper RenderWishListPopup(bool isUserLogged, string productId, string productLanguageId, bool isFavorite) 22 { 23 if (isUserLogged) 24 { 25 var favoritesUrl = "/Default.aspx?Id=" + Pageview.Page.ID + "&amp;CC{{favoriteAction}}MyLists=" + productId + "&amp;CC{{favoriteAction}}&amp;CC{{favoriteAction}}ListLanguageID=" + productLanguageId + "&amp;CC{{favoriteAction}}ListID={{listId}}"; 26 var isFavoriteClass = isFavorite ? "isFavorite" : ""; 27 var isLogedClass = isUserLogged ? isFavoriteClass : "noUser inactive"; 28 29 <div class="col-xs-12 col-sm-3 noPadding-right addWishList"> 30 <div class="@isLogedClass"> 31 <i class="fa fa-thumb-tack"></i><span>@Translate("pinToMyList", "Pin to My List")</span> 32 </div> 33 </div> 34 35 var itemArea = Pageview.Area.Item; 36 var userID = Pageview.User.ID; 37 var lists = Dynamicweb.Ecommerce.CustomerCenter.CustomerProductList.GetListByCustomerId(userID); 38 39 <div class="addToWishList col-xs-12 noPadding"> 40 <div class="col-xs-12 noPadding"> 41 <p class="col-xs-6">@Translate("saveTo", "Save To"):</p> 42 43 <div class="createListContainer"> 44 <a class="col-xs-6 createList">@Translate("createNewList", "Create New List")</a> 45 @{ 46 var paragraphId = GetString("ParagraphID"); 47 var formId = string.Concat(paragraphId, "AddListForm"); 48 var formAction = Helpers.GetCurrentUrl(true) + Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("WishLists")) + "?CC"+ itemArea["WishList"] +"=CreateList"; 49 } 50 <form class="DMForms col-xs-12 noPadding" id="@formId" name="@formId" action="@formAction" method="post"> 51 <input type="hidden" name="redirect" value="false"/> 52 <fieldset class="text mandatory col-xs-7 noPadding-right"> 53 <input type="text" name="CC_Name" id="CC_Name" placeholder="@Translate("List Name")"> 54 </fieldset> 55 <div class="col-xs-5"> 56 <button class="btn btn-primary" type="submit">@Translate("Create")</button> 57 </div> 58 </form> 59 </div> 60 61 @if (lists.Any()) 62 { 63 <ul> 64 @foreach (var list in lists) 65 { 66 isFavorite = list.Products.FirstOrDefault(x => x.ProductId == productId) != null; 67 isFavoriteClass = isFavorite ? "isFavorite" : ""; 68 var addText = Translate("pinToMyList", "Pin to My List"); 69 var removeText = Translate("unpin", "Unpin"); 70 var text = isFavorite ? removeText : addText; 71 var productAddToList = favoritesUrl.Replace("{{favoriteAction}}", "AddTo").Replace("{{listId}}",list.ListId.ToString()); 72 var productRemoveFromList = favoritesUrl.Replace("{{favoriteAction}}", "RemoveFrom").Replace("{{listId}}",list.ListId.ToString()).Replace("CCRemoveFromListID","ListID") + "&CCRemoveFromProductList=True"; 73 var favoriteUrl = isFavorite ? productRemoveFromList : productAddToList; 74 var listName = list.Name.IsNullOrEmpty() ? Translate("Default", "Default") : list.Name; 75 76 <li class="@listName.Replace(" ","")"> 77 <div class="col-xs-8 noPadding"> 78 <h2>@listName</h2> 79 <p>@list.ProductsCount @Translate("items", "Items")</p> 80 </div> 81 82 <div class="col-xs-4 noPadding"> 83 <a class="@isFavoriteClass addToList" data-id="@productId" href="@favoriteUrl"> 84 <i class="fa fa-thumb-tack"></i><span>@text</span> 85 </a> 86 </div> 87 </li> 88 } 89 </ul> 90 } 91 </div> 92 </div> 93 } 94 } 95 @helper RenderRibbons(List<LoopItem> ribbons, Dictionary<string, List<string>> ribbonsSettings) 96 { 97 if (ribbons.Any()) 98 { 99 var firstRibbon = true; 100 var ribbonCount = 0; 101 foreach (var ribbon in ribbons) 102 { 103 if (ribbon.GetBoolean("Ribbons.Option.IsSelected") && ribbonCount <= 1) 104 { 105 var colors = ribbonsSettings[ribbon.GetString("Ribbons.Option.Value")]; 106 var ribbonClass = firstRibbon ? "firstRibbon" : "secondRibbon"; 107 var ribbonName = ribbon.GetString("Ribbons.Option.Name"); 108 109 <div class="ribbon @ribbonName.ToLower().Replace(" ", "") @ribbonClass" style="background: @colors.FirstOrDefault();color: @colors.LastOrDefault();">@Translate(ribbonName)</div> 110 firstRibbon = false; 111 ribbonCount++; 112 } 113 } 114 } 115 } 116 @helper RenderProductDescription(string largeDescription, string prodId, bool noLogos = true) 117 { 118 var isLargeDescription = largeDescription.Length > 460; 119 var cssClass = isLargeDescription ? "seeMoreArea" : ""; 120 var containerClass = noLogos ? "" : "col-md-8"; 121 <div class="@containerClass col-xs-12 noPadding" id="@prodId"> 122 <div class="productDescription @cssClass col-xs-12 noPadding" itemprop="description"> 123 124 </div> 125 @if (isLargeDescription) 126 { 127 <div class="seeMoreButton" data-seeMore="@Translate("See More")" data-seeLess="@Translate("See Less")">@Translate("See More")</div> 128 } 129 130 @SnippetStart("jsOnLoad") 131 validateHtml("@HttpUtility.JavaScriptStringEncode(largeDescription)", "@prodId"); 132 @SnippetEnd("jsOnLoad") 133 </div> 134 } 135 @helper RenderProductFormatText(string productFormat, string productId, string languageId) 136 { 137 if (string.IsNullOrEmpty(productFormat)) 138 { 139 var prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(productId, "", languageId); 140 productFormat = prod.get_StockStatus(languageId).Text; 141 } 142 143 @RenderProductFormat(productFormat) 144 } 145 @helper RenderProductFormat(string productFormat, string downloadLink = null) 146 { 147 if (productFormat.IsNotNullOrEmpty()) 148 { 149 var format = productFormat.ToLower(); 150 var formatClass = string.Empty; 151 152 switch (format) 153 { 154 case "downloadable": 155 case "download": 156 formatClass = "fa-arrow-circle-o-down"; 157 break; 158 case "physical": 159 formatClass = "fa-file-text"; 160 break; 161 default: 162 formatClass = string.Empty; 163 break; 164 } 165 166 <i class="fa @formatClass"></i> 167 if (downloadLink.IsNotNullOrEmpty() && !downloadLink.Equals("null")) 168 { 169 <a href="@downloadLink">@productFormat</a> 170 } 171 else 172 { 173 @productFormat 174 } 175 } 176 } 177 @helper RenderProductFiles(string fileUrl, bool isLogedIn, string hidden, Dictionary<string,string> metaDataList = null, string productDescription = "") 178 { 179 if (fileUrl.IsNotNullOrEmpty()) 180 { 181 var fileName = productDescription.IsNotNullOrEmpty() ? productDescription : Path.GetFileNameWithoutExtension(fileUrl); 182 var fileFormat = Path.GetExtension(fileUrl); 183 var fileClass = string.Empty; 184 var listClass = string.Empty; 185 var url = "javascript:void(0);"; 186 187 if (fileFormat.ToLower() != ".jpg" && fileFormat.ToLower() != ".png") 188 { 189 switch (fileFormat.ToLower()) 190 { 191 case ".mp3": 192 fileName = metaDataList != null && metaDataList.ContainsKey(fileName + ".mp3")? metaDataList[fileName + ".mp3"] : fileName; 193 fileClass = "fa-play-circle-o" + (isLogedIn ? " play" : ""); 194 listClass = "playerElement"; 195 break; 196 case ".pdf": 197 fileClass = "fa-file-text preview"; 198 listClass = "documentElement"; 199 break; 200 default: 201 fileClass = "fa-arrow-circle-o-down download"; 202 url = fileUrl; 203 break; 204 } 205 206 <li class="@listClass @hidden" data-url="@fileUrl"><a href="@url"><i class="fa @fileClass"></i><span>@fileName</span></a></li> 207 } 208 } 209 } 210 @helper RenderRelatedProducts(List<LoopItem> relatedProducts, string cssClass, string productId = null, bool smallList = false) 211 { 212 relatedProducts = smallList ? relatedProducts.GroupBy(x => x.GetString("Ecom:Product:Field.ParentProductId.Value.Clean")).Select(x => x.First()).Take(4).ToList() : relatedProducts.GroupBy(x => x.GetString("Ecom:Product:Field.ParentProductId.Value.Clean")).Select(x => x.First()).Take(6).ToList(); 213 relatedProducts = productId.IsNotNullOrEmpty() ? relatedProducts.Where(s => s.GetString("Ecom:Product.ID") != productId).ToList() : relatedProducts.ToList(); 214 215 <ul class="rightColRelatedList"> 216 @foreach (var product in relatedProducts) 217 { 218 var prodNumber = product.GetString("Ecom:Product.Number"); 219 string relatedProductName; 220 string prodId; 221 Product parent = null; 222 223 if (!prodNumber.Contains("Parent_", StringComparison.InvariantCultureIgnoreCase)) 224 { 225 parent = Product.GetProductById(product.GetString("Ecom:Product:Field.ParentProductId.Value.Clean")); 226 relatedProductName = parent != null ? parent.Name : ""; 227 prodId = parent != null ? parent.Id : ""; 228 } 229 else 230 { 231 relatedProductName = product.GetString("Ecom:Product.Name"); 232 prodId = product.GetString("Ecom:Product.ID"); 233 } 234 235 var relatedProductLink = "/Default.aspx?ID=" + GetPageIdByNavigationTag("SearchResults") + "&ProductID=" + System.Web.HttpUtility.UrlEncode(prodId); 236 237 if (relatedProductName.IsNotNullOrEmpty()) 238 { 239 <li class="@cssClass"> 240 <figure> 241 <a href="@relatedProductLink"> 242 @if (parent != null) 243 { 244 @RenderProductImage(parent) 245 } 246 else 247 { 248 @RenderProductImage(product) 249 } 250 </a> 251 </figure> 252 <h3><a href="@relatedProductLink">@relatedProductName</a></h3> 253 </li> 254 } 255 } 256 </ul> 257 } 258 @helper RenderRelatedProducts(ProductCollection relatedProducts, string cssClass, string productId = null, bool smallList = false) 259 { 260 var products = productId.IsNotNullOrEmpty() ? relatedProducts.Where(product => product.Id != productId && product.ProductFieldValues.FirstOrDefault(x => x.ProductField.SystemName == "ParentProductId").Value.ToString() != productId) : relatedProducts; 261 products = products.GroupBy(product => product.ProductFieldValues.FirstOrDefault(x => x.ProductField.SystemName == "ParentProductId")?.Value).Select(x => x.First()).ToList(); 262 263 <ul class="rightColRelatedList"> 264 @foreach (var product in products.Take(6)) 265 { 266 var prodNumber = product.Number; 267 var relatedProductName = string.Empty; 268 var prodId = string.Empty; 269 Product parent = null; 270 271 if (!prodNumber.Contains("Parent_", StringComparison.InvariantCultureIgnoreCase)) 272 { 273 var parentProductId = product.ProductFieldValues.FirstOrDefault(x => x.ProductField.SystemName == "ParentProductId")?.Value; 274 if (parentProductId != null) 275 { 276 parent = Product.GetProductById(parentProductId.ToString()); 277 relatedProductName = parent != null ? parent.Name : ""; 278 prodId = parent != null ? parent.Id : ""; 279 } 280 } 281 else 282 { 283 relatedProductName = product.Name; 284 prodId = product.Id; 285 } 286 287 var relatedProductLink = "/Default.aspx?ID=" + GetPageIdByNavigationTag("SearchResults") + "&ProductID=" + HttpUtility.UrlEncode(prodId); 288 289 if (relatedProductName.IsNotNullOrEmpty()) 290 { 291 <li class="@cssClass"> 292 <figure> 293 <a href="@relatedProductLink"> 294 @if (parent != null) 295 { 296 @RenderProductImage(parent) 297 } 298 else 299 { 300 @RenderProductImage(product) 301 } 302 </a> 303 </figure> 304 <h3><a href="@relatedProductLink">@relatedProductName</a></h3> 305 </li> 306 } 307 } 308 </ul> 309 } 310 @helper RenderProductSearch() 311 { 312 var searchParameter = Sanitize.Parameter("q", ParameterType.LongText); 313 314 <div id="searchFormContainer" class="col-xs-12 noPadding productSearch"> 315 <form action="@Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("SearchResults"))" id="searchForm" class="pull-left"> 316 <fieldset class="TextInput mandatory"> 317 <label for="searchSubmit" class="hide">@Translate("search", "Search")</label> 318 <input id="searchSubmit" placeholder='@Translate("search")' data-error='@Translate("searchText", "Search for something")' type="text" name="q" value="@searchParameter"> 319 </fieldset> 320 <button class="btn searchButton search-submit" type="submit"> 321 <i class="fa fa-search"></i> 322 </button> 323 </form> 324 </div> 325 } 326 @helper RenderTrackingNumber(LoopItem orderLine) 327 { 328 foreach (var orderLineFields in orderLine.GetLoop("Order.OrderLineFields")) 329 { 330 var systemName = orderLineFields.GetString("Ecom:Order:OrderLine.OrderLineField.SystemName"); 331 var trackNumber = orderLineFields.GetString("Ecom:Order:OrderLine.OrderLineField.Value.Clean"); 332 if (trackNumber.IsNotNullOrEmpty() && systemName.Equals("TrackAndTraceNumber",StringComparison.InvariantCultureIgnoreCase)) 333 { 334 <a href="@trackNumber" target="_blank">@trackNumber.Split(',')[1]</a><br/> 335 } 336 } 337 } 338 @helper RenderMinQuantity(string loopCounter, int int_initQuantity) 339 { 340 <div class="minQuantityMessage hidden" id="@("quantity" + loopCounter)"> 341 <p> 342 @Translate("Enter the number of copies you will physically make and/or distribute electronically, including via email. ") 343 <a href="@(Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("CopyrightRules")))">@Translate("Click here for more information.")</a> 344 </p> 345 <label>@Translate("Minimum Qty")</label> 346 <input type="number" class="productQuantity" min="@int_initQuantity" data-prev-value="@int_initQuantity" value="@int_initQuantity"/> 347 </div> 348 } 349 @helper RenderProductImage(Product product, int width = 250, int height = 0, ImageProcessorSettings settings = null) 350 { 351 var productName = product.Name; 352 var productNumber = product.Number.Replace("Parent_","").Replace("/", "_"); 353 var pattern = "/Files/Files/WordMusic/Products/Product_Images/" + productNumber + ".jpg"; 354 var relatedImage = product.ImageSmall.IsNotNullOrEmpty() ? product.ImageSmall : product.ImageMedium.IsNotNullOrEmpty() ? product.ImageMedium : product.ImageLarge.IsNotNullOrEmpty() ? product.ImageLarge : pattern; 355 356 <img src="@Dna.Frontend.Images.GetImage(relatedImage, width, height, width, height, 550, 0, settings)" alt="@productName" title="@productName" class="img-responsive"/> 357 } 358 @helper RenderProductImage(LoopItem product, int width = 250, int height = 0, ImageProcessorSettings settings = null, string selectedVariant = null) 359 { 360 var productName = product.GetString("Ecom:Product.Name"); 361 var productNumber = product.GetString("Ecom:Product.Number").Replace("Parent_","").Replace("/", "_"); 362 productNumber = selectedVariant ?? productNumber; 363 var pattern = "/Files/Files/WordMusic/Products/Product_Images/" + productNumber + ".jpg"; 364 var relatedImage = product.GetString("Ecom:Product.ImageSmall.Default.Clean").IsNotNullOrEmpty() ? product.GetString("Ecom:Product.ImageSmall.Default.Clean") : product.GetString("Ecom:Product.ImageMedium.Default.Clean").IsNotNullOrEmpty() ? product.GetString("Ecom:Product.ImageMedium.Default.Clean") : product.GetString("Ecom:Product.ImageLarge.Default.Clean").IsNotNullOrEmpty() ? product.GetString("Ecom:Product.ImageLarge.Default.Clean") : pattern; 365 366 <img src="@Dna.Frontend.Images.GetImage(relatedImage, width, height, width, height, 550, 0, settings)" alt="@productName" title="@productName" class="img-responsive"/> 367 368 } 369 @helper RenderProductName(LoopItem orderLine, bool isSubscription = false) 370 { 371 var productName = orderLine.GetString("Ecom:Order:OrderLine.ProductName"); 372 var parentProduct = orderLine.GetString("Ecom:Product:Field.ParentProductId.Value.Clean"); 373 var parent = Dynamicweb.Ecommerce.Services.Products.GetProductById(parentProduct, "", true); 374 productName = parent != null && !isSubscription ? parent.Name : productName; 375 var description = orderLine.GetString("Ecom:Product:Field.ConfigDescription.Value.Clean"); 376 @productName 377 if (description.IsNotNullOrEmpty()) 378 { 379 <span> - </span>@description 380 } 381 } 382 @helper RenderChildProduct(LoopItem product, string samplePagesUrl, bool bol_userLogged, bool hasFile, bool hasImage) 383 { 384 var loopCounter = product.GetString("BOMProducts.LoopCounter"); 385 var relatedProductNumber = product.GetString("Ecom:Product.Number"); 386 var relatedProductId = product.GetString("Ecom:Product.ID"); 387 var productFormat = product.GetString("Ecom:Product:Field.Format.Value.Clean"); 388 var productNotes = product.GetString("Ecom:Product:Stock.DeliveryText"); 389 var productDescription = product.GetString("Ecom:Product:Field.ConfigDescription.Value.Clean"); 390 var minQuantity = product.GetString("Ecom:Product:Field.MinOrderQuantity.Value.Clean"); 391 var int_initQuantity = minQuantity.IsNotNullOrEmpty() ? int.Parse(minQuantity) : 1; 392 int_initQuantity = int_initQuantity < 1 ? 0 : int_initQuantity; 393 394 var sampleFile = samplePagesUrl + relatedProductNumber.Replace("/", "_") + ".pdf"; 395 var sampleImage = samplePagesUrl + relatedProductNumber.Replace("/", "_") + ".jpg"; 396 397 @SnippetStart("prodList") 398 <tr id="@relatedProductId"> 399 <td data-th="@Translate("Order Number")">@relatedProductNumber</td> 400 <td data-th="@Translate("Description")"> 401 @productDescription 402 @if (hasFile || hasImage) 403 { 404 if (bol_userLogged) 405 { 406 if (hasFile) 407 { 408 <span class="previewButton documentElement" data-url="@sampleFile"> @Translate("Preview")</span> 409 } 410 else 411 { 412 <span class="previewButton documentElement sampleImage" data-url="@Dna.Frontend.Images.GetImage(sampleImage)"> @Translate("Preview")</span> 413 <figure class="col-xs-12 hidden sampleImageArea"> 414 <div class="fa fa-search zoom-icon zoom-icon-in hidden-sm hidden-xs"></div> 415 <img src="@Dna.Frontend.Images.GetImage(sampleImage)" alt="@productDescription" title="@productDescription" class="img-responsive"/> 416 </figure> 417 } 418 } 419 else 420 { 421 <span class="loginButton previewButton"> @Translate("Login to preview")</span> 422 } 423 } 424 </td> 425 <td class="price" data-th="@Translate("Price")"> 426 @product.GetString("Ecom:Product.Price") 427 </td> 428 <td class="notes" data-th="@Translate("Notes")">@productNotes</td> 429 <td data-th="@Translate("Format")" class="productFormat"> 430 @RenderProductFormat(productFormat) 431 </td> 432 <td data-th="@Translate("Qty")" class="qty"> 433 @if (!product.GetBoolean("Ecom:Product.CategoryField.WordAx.OutofPrint.Value.Clean")) 434 { 435 <input type="hidden" name="@("productID" + loopCounter)" value='@relatedProductId'/> 436 <input type="hidden" name="@("ProductLoopCounter" + loopCounter)" value='@loopCounter'/> 437 <input type="number" id="@("quantity" + loopCounter)" name="@("quantity" + loopCounter)" class="productQuantity" min="@int_initQuantity"/> 438 } 439 </td> 440 441 @RenderMinQuantity(loopCounter, int_initQuantity) 442 </tr> 443 @SnippetEnd("prodList") 444 } 445 } 446 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 447 @using System 448 @using System.Linq 449 @using System.Web 450 @using Dna.UrlServices 451 @using Dynamicweb.Rendering 452 453 @helper RenderSubscriptionDiscount(bool hasSubscriptions) 454 { 455 if (Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) 456 { 457 var user = Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser(); 458 var itemArea = Pageview.Area.Item; 459 var wccGroupId = itemArea["WCCGroupId"]; 460 if (user.Groups.Any(x => x.ID.Equals(wccGroupId))) 461 { 462 @AddSubscriptionDiscount(hasSubscriptions, true); 463 } 464 else 465 { 466 @AddSubscriptionDiscount(hasSubscriptions); 467 } 468 } 469 else 470 { 471 @AddSubscriptionDiscount(hasSubscriptions); 472 } 473 } 474 475 @helper AddSubscriptionDiscount (bool hasSubscriptions, bool removeDiscount = false) 476 { 477 var order = Dynamicweb.Ecommerce.Orders.Order.GetOrderById(GetString("Ecom:Order.ID")); 478 var wccDiscount = order.OrderFieldValues.GetOrderFieldValue("WCCDiscount").Value; 479 if (order.OrderLines != null && (!removeDiscount && !wccDiscount.ToString().Equals(hasSubscriptions.ToString(),StringComparison.InvariantCultureIgnoreCase) || 480 (removeDiscount && wccDiscount.ToString().Equals("true",StringComparison.InvariantCultureIgnoreCase)))) 481 { 482 order.OrderFieldValues.GetOrderFieldValue("WCCDiscount").Value = !removeDiscount && hasSubscriptions; 483 order.Save(); 484 Dynamicweb.Ecommerce.Common.Context.SetCart(order); 485 Helpers.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); 486 } 487 } 488 @{ 489 var orderLines = GetLoop("OrderLines"); 490 var loadedVoucher = false; 491 var alertErrors = ""; 492 var promoCode = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("ChoralClub")); 493 var checkPromoCode = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("CheckInvalidCode")); 494 var recentProducts = GetLoop("eCom:Related.YouHaveSeenTheseProducts"); 495 var totalChoralClubDiscount = 0.00; 496 var orderLineTotalPrice = 0.00; 497 var formAction = SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID); 498 var vouchercode = GetString("Ecom:Order.Customer.VoucherCode"); 499 var hasVoucher = vouchercode.IsNotNullOrEmpty(); 500 var containerClass = hasVoucher ? "" : "open hasvoucher"; 501 var totaldiscount = GetDouble("Ecom:Order.TotalDiscount.Price"); 502 var hasSubscriptions = false; 503 var itemArea = Pageview.Area.Item; 504 var wccGroupId = itemArea["WCCGroupId"]; 505 var currentUserId = Pageview.User.ID; 506 } 507 508 @if (orderLines.Any()) 509 { 510 <div id="shoppingCartContainer"> 511 <div class="cartContainerHead col-xs-12 noPadding hidden-lg hidden-md hidden-sm"> 512 <a class="searchButton btn btn-primary pull-right" href="@SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("Checkout"))">@Translate("Checkout")</a> 513 </div> 514 <div class="col-xs-12 noPadding"> 515 <div class="col-xs-12" id="productContent"> 516 <header> 517 <div class="col-xs-12 col-sm-4 col-lg-8"></div> 518 <div class="col-xs-12 col-sm-2 col-lg-1 text-center">@Translate("Unit price")</div> 519 <div class="col-xs-12 col-sm-2 col-lg-1 text-center">@Translate("Qty")</div> 520 <div class="col-xs-12 col-sm-2 col-lg-1 text-center"><p>@Translate("Choral Club Discount")</p></div> 521 <div class="col-xs-12 col-sm-2 col-lg-1 text-center">@Translate("Total price")</div> 522 </header> 523 <ul class="cartProductsList"> 524 @foreach (var orderLine in orderLines) 525 { 526 var isProduct = orderLine.GetBoolean("Ecom:Order:OrderLine.IsProduct"); 527 var articleNum = orderLine.GetString("Ecom:Product.Number"); 528 529 if (isProduct || articleNum.IsNotNullOrEmpty()) 530 { 531 var isSubscription = orderLine.GetBoolean("Ecom:Product:Field.Subscription.Value.Clean"); 532 var productId = orderLine.GetString("Ecom:Order:OrderLine.ProductID"); 533 var increment = orderLine.GetString("Ecom:Order:OrderLine.IncrementLink"); 534 var decrement = orderLine.GetString("Ecom:Order:OrderLine.DecrementLink"); 535 var minQuantity = orderLine.GetString("Ecom:Product:Field.MinOrderQuantity.Value.Clean"); 536 var initQuantity = orderLine.GetString("Ecom:Order:OrderLine.Quantity"); 537 var parentProduct = orderLine.GetString("Ecom:Product:Field.ParentProductId.Value.Clean"); 538 parentProduct = parentProduct.IsNullOrEmpty() ? productId : parentProduct; 539 var productUrl = "/Default.aspx?ID=" + GetPageIdByNavigationTag("SearchResults") + "&ProductID=" + System.Web.HttpUtility.UrlEncode(parentProduct); 540 productUrl = isSubscription ? "href=" + SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("WordChoralClub")) : "href=" + productUrl; 541 var productFormat = orderLine.GetString("Ecom:Product:Field.Format.Value.Clean"); 542 var orderLineId = orderLine.GetString("Ecom:Order:OrderLine.Id"); 543 var isDownload = productFormat.ToLower() == "download"; 544 var isDiscount = orderLine.GetBoolean("Ecom:Order:OrderLine.IsDiscount"); 545 hasSubscriptions = hasSubscriptions || isSubscription; 546 547 if (GetInteger("Ecom:Order.OrderLines.ProductLinesCount") == 1) 548 { 549 @:<li> 550 } 551 else 552 { 553 @:</li> 554 @:<li> 555 } 556 557 <div class="col-sm-4 col-xs-12 col-lg-8 noPaddingLeft noPadding-sm"> 558 <figure class="text-center col-sm-4 col-xs-3 col-lg-2 noPadding-sm"> 559 <a @productUrl> 560 @RenderProductImage(orderLine, 95, 0) 561 </a> 562 </figure> 563 <div class="col-sm-8 col-xs-9 col-xs-offset-3 col-sm-offset-0 noPadding prodName"> 564 <h2> 565 <a @productUrl> 566 @RenderProductName(orderLine, isSubscription) 567 </a> 568 @{ 569 var deliveryCountry = GetString("Ecom:Order.Delivery.Country.Code"); 570 if (!isDownload && !isSubscription && !deliveryCountry.Equals("CA", StringComparison.InvariantCultureIgnoreCase) && !deliveryCountry.Equals("US", StringComparison.InvariantCultureIgnoreCase) && !deliveryCountry.Equals("", StringComparison.InvariantCultureIgnoreCase) && !GetString("Ecom:Order.Delivery.Country").Equals("", StringComparison.InvariantCultureIgnoreCase)) 571 { 572 <div class="shippingWarning"> 573 <i class="fa fa-exclamation-circle"></i> 574 <p>@Translate("This item cannot be shipped to international customers")</p> 575 </div> 576 } 577 } 578 </h2> 579 580 <div class="itemDetails"> 581 <p>@articleNum</p> 582 </div> 583 </div> 584 </div> 585 <div class="col-xs-6 col-xs-offset-3 col-sm-2 col-sm-offset-0 col-lg-1 price text-center"> 586 @orderLine.GetString("Ecom:Product.Price") 587 </div> 588 <div class="col-xs-6 col-xs-offset-3 col-sm-2 col-sm-offset-0 col-lg-1 noPadding quantity"> 589 <form class="cartChange" id="@productId" method="POST" action="@formAction"> 590 <b class="hidden-lg hidden-md hidden-sm">@Translate("Qty")</b> 591 592 <a href="@decrement"><i class="fa fa-minus hidden-xs"></i></a> 593 <input maxlength="5" class="productQuantity" value='@initQuantity' min="@minQuantity" data-available='@orderLine.GetString("Ecom:Product.AvailableAmount")' type="number" name="@orderLine.GetString("Ecom:Order:OrderLine.Quantity.Input.Name")"/> 594 <a href="@increment"><i class="fa fa-plus hidden-xs"></i></a> 595 596 <button class="cartUpdateBtn btn btn-primary hidden-xs" type="submit" value='@Translate("update", "Update")'> 597 <span>@Translate("update", "Update")</span> 598 </button> 599 </form> 600 </div> 601 <div class="col-xs-6 col-xs-offset-3 col-sm-2 col-sm-offset-0 col-lg-1 text-center noPadding" id="@orderLineId"> 602 @if (isDiscount) 603 { 604 <span>-</span> 605 @orderLine.GetString("Ecom:Product.Price") 606 } 607 else 608 { 609 var orderLineChoralClubDiscount = 0.00; 610 foreach (var orderlineDiscount in orderLines.Where(x => x.GetBoolean("Ecom:Order:OrderLine.IsDiscount") && x.GetString("Ecom:Order:OrderLine.ParentLineID").Equals(orderLine.GetString("Ecom:Order:OrderLine.Id")))) 611 { 612 var productDiscountVal = orderlineDiscount.GetString("Ecom:Order:OrderLine.Price.Price"); 613 if (productDiscountVal != "0.00") 614 { 615 var orderL = Dynamicweb.Ecommerce.Orders.OrderLine.GetOrderLineById(orderlineDiscount.GetString("Ecom:Order:OrderLine.Id")); 616 var discount = Dynamicweb.Ecommerce.Orders.Discounts.Discount.GetDiscountById(Convert.ToInt64(orderL.DiscountId)); 617 if (discount.Description.Equals("Choral Club Discount", StringComparison.InvariantCultureIgnoreCase) 618 || discount.Description.Equals("WCCDiscount", StringComparison.InvariantCultureIgnoreCase)) 619 { 620 totalChoralClubDiscount += double.Parse(productDiscountVal); 621 orderLineChoralClubDiscount = double.Parse(productDiscountVal); 622 } 623 } 624 } 625 if (orderLineChoralClubDiscount != 0.00) 626 { 627 <b class="hidden-lg hidden-md hidden-sm">@Translate("Choral Club Discount"):</b> 628 @Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderLineChoralClubDiscount, true) 629 orderLineTotalPrice = double.Parse(orderLine.GetString("Ecom:Order:OrderLine.TotalPriceWithoutSymbol")) - Math.Abs(orderLineChoralClubDiscount); 630 } 631 } 632 </div> 633 <div class="col-xs-3 col-sm-2 col-lg-1 noPadding totalPrice"> 634 <div class="col-xs-9 col-sm-7 col-md-9 text-right noPadding"> 635 <span>@(orderLineTotalPrice != 0.00 ? Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderLineTotalPrice, true) : orderLine.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted"))</span> 636 </div> 637 638 <a class="removeFromCart btn-remove" href="@orderLine.GetString("Ecom:Order:OrderLine.DeleteLink")"> 639 <i class="fa fa-times"></i> 640 </a> 641 642 <div class="orderLineDiscountDisplay col-xs-12 col-sm-7 col-md-9 text-right noPadding"> 643 <span></span> 644 </div> 645 646 </div> 647 } 648 } 649 650 @RenderSubscriptionDiscount(hasSubscriptions) 651 </ul> 652 </div> 653 </div> 654 <div class="col-xs-12 totalArea noPadding"> 655 <div id="promoCodeContainer" class="col-xs-12 col-sm-5 @containerClass" date-groupId="@wccGroupId" date-userId="@currentUserId"> 656 <span class="pull-left col-xs-12 noPadding-left">@Translate("Enter a Coupon Code:")</span> 657 658 <form class="cartPromo cartPromoForm col-xs-12 noPadding" method="POST" action="@formAction"> 659 <input data-checkCode="@checkPromoCode" type="text" id="EcomOrderVoucherCode" name="EcomOrderVoucherCode" value='@vouchercode'/> 660 <button class="btn btn-primary addPromo"> 661 @Translate("Apply") 662 </button> 663 </form> 664 665 <p class="col-xs-12 noPadding" id="invalidPromoCode" data-choralClub="@Translate("Sorry, this discount is for Choral Club members only. Not a member?") <a href='@promoCode'>@Translate("Click here")</a> @Translate("to join.")" data-invalid="@Translate("invalidPromotionCode", "We’re sorry, this coupon code is invalid. Please try again.")" data-inactive="@Translate("inactivePromotionCode", "We're sorry, this promotion code is not yet active.")" data-expired="@Translate("expiredPromotionCode", "We're sorry, this promotion code has expired.")"></p> 666 667 <p class="col-xs-12 noPadding">@Translate("Want to receive our member discounts?") <a href="@promoCode">@Translate("Click here")</a> @Translate("or call (888) 324-9673 to find out how.")</p> 668 </div> 669 670 <ul class="col-xs-12 col-sm-5 col-sm-offset-2 noPadding totalContainer"> 671 672 @if (hasVoucher) 673 { 674 <li class="col-xs-12 noPadding voucherDiscount"> 675 <div class="pull-left col-xs-5"> 676 @Translate("Cupon Code: ")@vouchercode 677 </div> 678 679 <form class="cartPromo pull-left col-xs-7 text-right" method="POST" action="@formAction"> 680 <input type="hidden" name="EcomOrderVoucherCode" value=""/> 681 682 <button class="removePromo btn-remove" type="submit"> 683 <i class="fa fa-times"></i> 684 </button> 685 </form> 686 687 <p id="couponMessage">@Translate("Your coupon code has been added to this order. If your order is eligible to receive this discount, then it will be calculated and applied to your order total at checkout.")</p> 688 </li> 689 } 690 691 @{ 692 var orderDiscount = totaldiscount - totalChoralClubDiscount; 693 } 694 @if (orderDiscount < 0) 695 { 696 <li class="col-xs-12 noPadding discount"> 697 <div class="col-xs-6"> 698 <span>@Translate("Discount")</span> 699 </div> 700 <div class="col-xs-6 text-right"> 701 @Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true) 702 </div> 703 </li> 704 } 705 706 <li class="col-xs-12 noPadding subtotal"> 707 <div class="col-xs-6 text-left"> 708 @Translate("Subtotal") 709 </div> 710 <div class="col-xs-6 text-right"> 711 @{ 712 var subtotal = GetDouble("Ecom:Order.PriceWithoutFees.Price") == 0 ? GetDouble("Ecom:Order.PriceWithoutFees.Price") : GetDouble("Ecom:Order.PriceWithoutFees.Price") - GetDouble("Ecom:Order.Taxes.Total.Price"); 713 } 714 @Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, subtotal, true) 715 </div> 716 </li> 717 718 @if (GetString("Ecom:Order.ShippingMethodID").IsNotNullOrEmpty()) 719 { 720 <li class="col-xs-12 noPadding"> 721 <div class="col-xs-6 text-left noPadding-right"> 722 @Translate("Shipping Fee ") (@GetString("Ecom:Order.ShippingMethod")) 723 </div> 724 <div class="col-xs-6 text-right"> 725 @GetString("Ecom:Order.ShippingFee.PriceWithoutVATFormatted") 726 </div> 727 </li> 728 } 729 730 @if (GetDouble("Ecom:Order.OrderLines.TaxLinesCount") > 0) 731 { 732 <li class="col-xs-12 noPadding"> 733 <div class="col-xs-6 text-left"> 734 @Translate("Taxes") 735 </div> 736 <div class="col-xs-6 text-right"> 737 @GetString("Ecom:Order.Taxes.Total") 738 </div> 739 </li> 740 } 741 742 <li class="col-xs-12 noPadding"> 743 <div class="total" data-totalPrice="@GetString("Ecom:Order.Price")"> 744 <div class="col-xs-6 noPadding"> 745 <span>@Translate("*Total")</span><br/> 746 </div> 747 <div class="col-xs-6 text-right"> 748 @GetString("Ecom:Order.Price") 749 </div> 750 @if (totalChoralClubDiscount != 0) 751 { 752 <p class="memberDiscount">@Translate("As a Choral Club member, you saved ")@Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, Math.Abs(totalChoralClubDiscount), true)</p> 753 } 754 else 755 { 756 <p>@Translate("As a Choral Club member you would've saved 20%!")</p> 757 } 758 </div> 759 <p>@Translate("*Shipping and Taxes calculated at checkout")</p> 760 </li> 761 </ul> 762 </div> 763 <div class="cartContainerHead col-xs-12 noPadding"> 764 <a class="searchButton btn btn-primary pull-right" href="@SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("Checkout"))">@Translate("Checkout")</a> 765 </div> 766 </div> 767 } 768 else 769 { 770 <div class="col-xs-12 noPadding"> 771 @Translate("Your shopping cart needs items.") 772 </div> 773 if (recentProducts.Any()) 774 { 775 <div class="col-xs-12 noPadding promotedProducts"> 776 <h2 class="header">@Translate("Recently viewed")</h2> 777 @RenderRelatedProducts(recentProducts, "col-xs-6 col-sm-3 col-md-2") 778 </div> 779 } 780 @SnippetStart("jsOnLoad") 781 @:onLoadClearStorage(); 782 @SnippetEnd("jsOnLoad") 783 } 784 @SnippetStart("jsOnLoad") 785 onLoadShoppingCart("@alertErrors"); 786 @SnippetEnd("jsOnLoad")