Latest Orders

Processed
Error executing template "Designs/Hewitt/DataManagement/Publishings/Custom/Orders.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_11a3173828b045039e9052243a203171.<>c__DisplayClass205_0.b__0(TextWriter __razor_helper_writer) in c:\Domains\Sites\hewittrad.com\Files\Templates\Designs\Hewitt\DataManagement\Publishings\Custom\Orders.cshtml:line 5741
   at CompiledRazorTemplates.Dynamic.RazorEngine_11a3173828b045039e9052243a203171.Execute() in c:\Domains\Sites\hewittrad.com\Files\Templates\Designs\Hewitt\DataManagement\Publishings\Custom\Orders.cshtml:line 6334
   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 Dynamicweb.Rendering 4 @using System.Linq 5 @using Dynamicweb.Frontend 6 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 7 @using System 8 @using System.Linq 9 @using System.Text 10 @using System.Web 11 @using System.Collections.Generic 12 @using Dna.Frontend 13 @using Dna.Frontend.UI 14 @using Dna.Frontend.Forms 15 @using Dna.UrlServices 16 @using Dna.Validation 17 @using Dynamicweb.Core 18 @using Dynamicweb.Forms 19 @using Dynamicweb.Content 20 @using Dynamicweb.Ecommerce 21 @using Dynamicweb.Rendering 22 @using Dynamicweb.Security.UserManagement 23 @using ImageSettings = Dna.Frontend.UI.ImageSettings 24 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 25 @using System 26 @using System.IO 27 @using System.Web 28 @using System.Linq 29 @using System.Text 30 @using System.Text.RegularExpressions 31 @using System.Collections.Generic 32 @using System.Collections.Specialized 33 @using Dna.Frontend 34 @using Dna.Validation 35 @using Dna.Frontend.UI 36 @using Dna.UrlServices 37 @using Dna.Frontend.Forms 38 @using Dynamicweb.Core 39 @using Dynamicweb.Forms 40 @using Dynamicweb.Rendering 41 @functions{ 42 43 #region Url functions 44 45 public string GetCustomerCenterSortUrl(string field, string listType = "Order") 46 { 47 var paragraphId = Pageview.CurrentParagraph.ID.ToString(); 48 var sortDirectionParameter = "CCSort" + listType + paragraphId; 49 var sortFieldParameter = "CC" + listType + "ByField" + paragraphId; 50 var sortDirection = Sanitize.Parameter(sortDirectionParameter) == "Desc" || Sanitize.Parameter(sortFieldParameter) != field ? "Asc" : "Desc"; 51 52 if (field.IsNotNullOrEmpty()) 53 { 54 return "/Default.aspx?Id=" + Pageview.Page.ID + "&" + sortFieldParameter + "=" + field + "&" + sortDirectionParameter + "=" + sortDirection; 55 } 56 57 return string.Empty; 58 } 59 60 public string GetDataListSortUrl(string field) 61 { 62 var paragraphId = Pageview.CurrentParagraph.ID.ToString(); 63 var sortDirectionParameter = "sortorder"; 64 var sortFieldParameter = "sortby"; 65 var sortByParameter = Sanitize.Parameter(sortFieldParameter).IsNotNullOrEmpty() ? Sanitize.Parameter(sortFieldParameter) : string.Empty; 66 var sortOrderParameter = Sanitize.Parameter(sortDirectionParameter).IsNotNullOrEmpty() ? Sanitize.Parameter(sortDirectionParameter) : "ASC"; 67 var sortDirection = sortOrderParameter.ToUpper() == "DESC" || sortByParameter != field ? "ASC" : "DESC"; 68 69 if (field.IsNotNullOrEmpty()) 70 { 71 return "/Default.aspx?Id=" + Pageview.Page.ID + "&" + sortFieldParameter + "=" + field + "&" + sortDirectionParameter + "=" + sortDirection + "&ViewPID=" + paragraphId; 72 } 73 return string.Empty; 74 } 75 76 public string GetSortFieldParameter(string key, string field = "", string listType = "Order") 77 { 78 var paragraphId = Pageview.CurrentParagraph.ID.ToString(); 79 if (key.IsNullOrEmpty()) throw new NotSupportedException("'key' is a required field"); 80 81 switch (key) 82 { 83 case "name": 84 var parameter = "CC" + listType + "ByField" + paragraphId; 85 return Sanitize.Parameter(parameter); 86 case "value": 87 if (field.IsNullOrEmpty()) return "asc"; 88 var sortDirectionParameter = "CCSort" + listType + paragraphId; 89 var sortFieldParameter = "CC" + listType + "ByField" + paragraphId; 90 return Sanitize.Parameter(sortDirectionParameter) == "Desc" || Sanitize.Parameter(sortFieldParameter) != field ? "Asc" : "Desc"; 91 default: 92 throw new NotSupportedException(string.Format("The key '{0}' in not supported", key)); 93 } 94 } 95 96 #endregion Url functions 97 98 #region Generic functions 99 100 public static string GetAttributes(Dictionary<string, string> attributes) 101 { 102 if (attributes == null || !attributes.Any()) 103 { 104 return string.Empty; 105 } 106 107 var attributesConcat = attributes.Aggregate(string.Empty, (current, attribute) => current + GetAttribute(attribute.Key, attribute.Value)); 108 109 return attributesConcat; 110 } 111 112 public static string GetAttribute(string attributeName, string attributeValue) 113 { 114 if (attributeValue.IsNullOrEmpty() && !attributeName.Equals("value", StringComparison.InvariantCultureIgnoreCase)) return string.Empty; 115 return " " + attributeName + "=\"" + attributeValue + "\""; 116 } 117 118 #endregion Generic functions 119 120 #region Files functions 121 122 const string ImagesListTitleKey = "title"; 123 const string ImagesListImageKey = "image"; 124 125 /// <summary> 126 /// Gets the list of files from a folder. 127 /// </summary> 128 /// <return>Item1 is filename (with extension), Item2 is the title and Item3 is the FileType.</return> 129 public static IEnumerable<Tuple<string, string, FileType>> GetFilesInFolder(string defaultFile, string searchPattern, string fileTitle = "", bool addDefaultFile = true) 130 { 131 var files = new List<Tuple<string,string,FileType>>(); 132 try 133 { 134 var mapPath = HttpContext.Current.Server.MapPath(defaultFile); 135 var folderServerPath = Path.GetDirectoryName(mapPath); 136 137 if (folderServerPath == null || !Directory.Exists(folderServerPath)) return files; 138 139 // Get Images from folder 140 const string temp = @"\"; 141 const string metafield = "title"; 142 var metadata = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(defaultFile); 143 var title = metadata != null && metadata.GetValue(metafield).IsNotNullOrEmpty() ? metadata.GetValue(metafield) : fileTitle; 144 var folderWebPath = defaultFile.Contains("/") ? defaultFile.Substring(0, defaultFile.LastIndexOf("/", StringComparison.Ordinal)) : defaultFile; 145 146 if (addDefaultFile && File.Exists(mapPath)) 147 { 148 files.Add(new Tuple<string, string, FileType>(defaultFile, title, defaultFile.GetFileType())); 149 } 150 151 foreach (var file in Directory.GetFiles(folderServerPath, searchPattern)) 152 { 153 var filePath = folderWebPath + "/" + file.Substring(file.LastIndexOf(temp, StringComparison.Ordinal) + 1, file.Length - file.LastIndexOf(temp, StringComparison.Ordinal) - 1); 154 metadata = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(filePath); 155 title = metadata != null && metadata.GetValue(metafield).IsNullOrEmpty() ? metadata.GetValue(metafield) : fileTitle; 156 157 files.Add(new Tuple<string, string, FileType>(filePath, title, file.GetFileType())); 158 } 159 } 160 catch (Exception ex){} 161 162 return files; 163 } 164 /// <summary> 165 /// Gets the list of image or HTML5 video files from a folder. 166 /// </summary> 167 /// <return>Item1 is filename (with extension), Item2 is the title and Item3 is the FileType (Image, Video).</return> 168 public static IEnumerable<Tuple<string,string,FileType>> GetMediaFilesInFolder(string defaulMedia, string searchPattern, string defaultName = "", bool addDefaultMedia = true) 169 { 170 return GetFilesInFolder(defaulMedia, searchPattern, defaultName, addDefaultMedia).Where(f => f.Item3 == FileType.Image || f.Item3 == FileType.Video).ToList(); 171 } 172 173 #endregion Files functions 174 175 #region Image functions 176 177 public static Dictionary<string, string> GetWidthAndHeightFromQueryString(string imageSource, bool addSource = false) 178 { 179 var widthAndHeight = new Dictionary<string, string>(); 180 181 if(imageSource.Contains("?")){ 182 var querySubstring = imageSource.Substring(imageSource.LastIndexOf('?') + 1); 183 var queryParams = HttpUtility.HtmlDecode(querySubstring).Split('&'); 184 185 if (!queryParams.Any()) 186 return widthAndHeight; 187 188 foreach (var param in queryParams.Where(k => k.StartsWith("width") || k.StartsWith("height"))) 189 { 190 var keyValuePair = param.Split('='); 191 192 if (keyValuePair[1].IsNotNullOrEmpty()) 193 { 194 widthAndHeight.Add(keyValuePair[0].ToLower(), keyValuePair[1]); 195 } 196 } 197 } 198 else if(imageSource.Contains("width") || imageSource.Contains("height")) 199 { 200 var queryParams = imageSource.Split('/'); 201 var imgParam = string.Empty; 202 203 foreach (var param in queryParams) 204 { 205 switch (imgParam) 206 { 207 case "width": 208 widthAndHeight.Add("width", param); 209 break; 210 case "height": 211 widthAndHeight.Add("height", param); 212 break; 213 } 214 215 switch (param) 216 { 217 case "width": 218 imgParam = "width"; 219 break; 220 case "height": 221 imgParam = "height"; 222 break; 223 default: 224 imgParam = string.Empty; 225 break; 226 } 227 } 228 } 229 230 if (addSource && imageSource.IsNotNullOrEmpty()) 231 { 232 widthAndHeight.Add("srcset", imageSource); 233 } 234 235 return widthAndHeight; 236 } 237 238 #endregion Image functions 239 240 #region Form Field functions 241 242 public string GetWrapperStart(bool includeWrapper, FieldType fieldType, string htmlElement, bool isRequired = false, string fieldClass = "") 243 { 244 if (!includeWrapper || htmlElement.IsNullOrEmpty()) return string.Empty; 245 var cssClass = new List<string> {fieldType.ToString().ToLower()}; 246 247 if (fieldClass.IsNotNullOrEmpty()) 248 cssClass.Add(fieldClass); 249 if (isRequired) 250 cssClass.Add("mandatory"); 251 252 var attributes = new Dictionary<string, string>() 253 { 254 {"class", string.Join(" ", cssClass)} 255 }; 256 257 return GetHtmlElement(htmlElement, attributes); 258 } 259 260 public string GetWrapperEnd(bool includeWrapper, string htmlElement) 261 { 262 return !includeWrapper ? string.Empty : GetHtmlElement(htmlElement, true); 263 } 264 265 public string GetControlWithRequiredClass(bool isRequired, string control, string fieldClass = "") 266 { 267 if (!isRequired) return control; 268 if (fieldClass.IsNotNullOrEmpty()) fieldClass += " "; 269 fieldClass += "mandatory"; 270 var regex = new Regex(Regex.Escape(" ")); 271 return regex.Replace(control, " class=\"" + fieldClass + "\" ", 1); 272 } 273 274 public static string GetAttributes(FieldSettings settings, bool returnFieldType = true) 275 { 276 var attributes = new StringBuilder(); 277 if (returnFieldType) 278 { 279 var fieldType = string.Empty; 280 switch (settings.Type) 281 { 282 case FieldType.Select: 283 break; 284 case FieldType.Checkboxlist: 285 fieldType = FieldType.Checkbox.ToString().ToLower(); 286 break; 287 case FieldType.DatetimeLocal: 288 fieldType = "datetime-local"; 289 break; 290 case FieldType.Textarea: 291 case FieldType.File: 292 case FieldType.Text: 293 case FieldType.Hidden: 294 case FieldType.Submit: 295 case FieldType.Reset: 296 case FieldType.Radio: 297 case FieldType.Checkbox: 298 case FieldType.Divider: 299 case FieldType.Image: 300 case FieldType.Password: 301 case FieldType.Textstring: 302 case FieldType.Button: 303 case FieldType.Search: 304 case FieldType.Email: 305 case FieldType.Url: 306 case FieldType.Tel: 307 case FieldType.Number: 308 case FieldType.Range: 309 case FieldType.Date: 310 case FieldType.Month: 311 case FieldType.Week: 312 case FieldType.Time: 313 case FieldType.Datetime: 314 case FieldType.Color: 315 case FieldType.Unknown: 316 default: 317 fieldType = settings.Type.ToString().ToLower(); 318 break; 319 } 320 if (!settings.Attributes.ContainsKey("type")) 321 { 322 attributes.Append(GetAttribute("type", fieldType)); 323 } 324 } 325 attributes.Append(GetAttribute("class", settings.CssClass)); 326 attributes.Append(GetAttribute("id", settings.Id)); 327 attributes.Append(GetAttribute("name", settings.SystemName)); 328 if (settings.Type != FieldType.Textarea) 329 { 330 attributes.Append(GetAttribute("value", settings.Value)); 331 } 332 if (settings.Type == FieldType.Email || settings.Type == FieldType.Password || settings.Type == FieldType.Search || settings.Type == FieldType.Tel || settings.Type == FieldType.Text || settings.Type == FieldType.Url) 333 { 334 // Only works wit these types 335 attributes.Append(GetAttribute("placeholder", settings.Placeholder)); 336 } 337 if (settings.Type == FieldType.Datetime) 338 { 339 attributes.Append(GetAttribute("placeholder", "&#x1f4c5;")); 340 } 341 if (settings.Type != FieldType.Checkboxlist) 342 { 343 attributes.Append(GetAttribute("required", settings.IsRequired)); 344 } 345 attributes.Append(GetAttributes(settings.Attributes)); 346 return attributes.ToString(); 347 } 348 349 public static string GetAttributes(FieldOption optionSettings, FieldType fieldType = FieldType.Select) 350 { 351 var attributes = new StringBuilder(); 352 if (fieldType != FieldType.Select) 353 { 354 attributes.Append(GetAttribute("name", optionSettings.SystemName)); 355 } 356 attributes.Append(GetAttribute("value", optionSettings.Value)); 357 attributes.Append(GetAttributes(optionSettings.Attributes)); 358 return attributes.ToString(); 359 } 360 361 public static string GetAttribute(string attributeName, bool attributeValue) 362 { 363 if (!attributeValue) return string.Empty; 364 return " " + attributeName + "=\"" + attributeName + "\""; 365 } 366 367 public static string GetAttributeString(string string1 = "", string string2 = "") 368 { 369 var result = new List<string>(); 370 371 if (string1.IsNotNullOrEmpty()) 372 result.AddRange(string1.Split(' ').ToList()); 373 if (string2.IsNotNullOrEmpty()) 374 result.AddRange(string2.Split(' ').ToList()); 375 376 return string.Join(" ", result); 377 } 378 379 #endregion 380 381 #region Dynamicweb Template Engine Workaround 382 383 public static string GetHtmlElement(string element, bool isClosingElement = false) 384 { 385 return GetHtmlElementForDw(element, null, string.Empty, isClosingElement); 386 } 387 388 public static string GetHtmlElement(string element, Dictionary<string, string> attributes, bool isClosingElement = false) 389 { 390 return GetHtmlElementForDw(element, attributes, string.Empty, isClosingElement); 391 } 392 393 public static string GetHtmlElement(string element, string processedAttributes, bool isClosingElement = false) 394 { 395 return GetHtmlElementForDw(element, null, processedAttributes, isClosingElement); 396 } 397 398 private static string GetHtmlElementForDw(string element, Dictionary<string, string> attributes = null, string processedAttributes = "", bool isClosingElement = false) 399 { 400 var result = new StringBuilder("<"); 401 402 if (attributes != null || processedAttributes.IsNotNullOrEmpty()) 403 { 404 result.Append(element); 405 if (attributes != null) 406 { 407 result.Append(GetAttributes(attributes)); 408 } 409 else if (processedAttributes.IsNotNullOrEmpty()) 410 { 411 result.Append(processedAttributes); 412 } 413 if (isClosingElement) 414 { 415 result.Append("/"); 416 } 417 } 418 else 419 { 420 if (isClosingElement) 421 { 422 result.Append("/"); 423 } 424 result.Append(element); 425 } 426 427 result.Append(">"); 428 429 return result.ToString(); 430 } 431 432 #endregion Dynamicweb Template Engine Workaround 433 } 434 @{ 435 436 @* Tab helpers *@ 437 @helper InternalRenderTabHeader(string key, string label, string cssClass = "") 438 { 439 @SnippetStart("tabHeaders") 440 <li class="@cssClass"> 441 <a href="@key">@label</a> 442 </li> 443 @SnippetEnd("tabHeaders") 444 } 445 446 447 @* Paging helpers *@ 448 @helper InternalRenderGoToFirstPage(NameValueCollection queryParameters, string pageNumQueryParameter, int currentPage, int numOfPages, int loopPageSize, int currentPageNum = 0) 449 { 450 if (currentPageNum == 0) 451 { 452 currentPageNum = currentPage; 453 } 454 455 if (currentPage > 2 && numOfPages > loopPageSize && currentPageNum != 1) 456 { 457 queryParameters.Remove(pageNumQueryParameter); 458 @InternalRenderPageItem(queryParameters, "1") 459 @InternalRenderEllipsis() 460 } 461 } 462 463 @helper InternalRenderGoToLastPage(NameValueCollection queryParameters, string pageNumQueryParameter, int currentPage, int numOfPages, int loopPageSize, int endPage) 464 { 465 if (currentPage < numOfPages - 1 && numOfPages > loopPageSize && endPage != numOfPages) 466 { 467 queryParameters = Helpers.UpdateQueryStringKeyValue(queryParameters, pageNumQueryParameter, numOfPages.ToString()); 468 @InternalRenderEllipsis() 469 @InternalRenderPageItem(queryParameters, numOfPages.ToString()) 470 } 471 } 472 473 @helper InternalRenderPageItem(NameValueCollection queryParameters, string pageNum, string cssClass = "") 474 { 475 var url = Helpers.GetCurrentUrl(true, true); 476 var href = Helpers.BuildUri(url, queryParameters); 477 478 <li class="@cssClass"> 479 <a href="@href.PathAndQuery"> 480 @pageNum 481 </a> 482 </li> 483 } 484 485 @helper InternalRenderPageItem(string href, string label, string cssPartialClass, IconPosition position) 486 { 487 <li> 488 <a href="@href"> 489 @RenderIcon(cssPartialClass, label, position) 490 </a> 491 </li> 492 } 493 494 @helper InternalRenderEllipsis() 495 { 496 <li> 497 <span>...</span> 498 </li> 499 } 500 501 502 @* Form field helpers *@ 503 @helper InternalRenderLabel(FieldSettings settings) 504 { 505 @InternalRenderLabel(settings.Label, settings.TranslateKeyForLabel) 506 } 507 508 @helper InternalRenderLabel(string label, string translateKey = "") 509 { 510 @( translateKey.IsNotNullOrEmpty() ? Translate(translateKey) : label) 511 } 512 513 @helper InternalRenderCheckboxField(FieldSettings settings) 514 { 515 if (settings.SystemName.IsNotNullOrEmpty() || settings.Control.IsNotNullOrEmpty()) 516 { 517 settings.Assert(FieldType.Checkbox); 518 if (settings.IsChecked && !settings.Attributes.ContainsKey("checked")) 519 { 520 settings.Attributes.Add("checked", "checked"); 521 } 522 523 @InternalRenderFieldHeader(settings, false) 524 525 if (settings.Label.IsNotNullOrEmpty() || settings.TranslateKeyForLabel.IsNotNullOrEmpty()) 526 { 527 var cssClassList = new List<string> {settings.Type.ToString().ToLower(), settings.LabelCssClass}; 528 var cssClass = string.Join(" ", cssClassList.Where(s => s.IsNotNullOrEmpty())); 529 530 if (!settings.LabelAttributes.ContainsKey("class")) 531 { 532 settings.LabelAttributes.Add("class", cssClass); 533 } 534 else 535 { 536 settings.LabelAttributes["class"] = string.Concat(cssClass, " ", settings.LabelAttributes["class"]); 537 } 538 if (!settings.LabelAttributes.ContainsKey("for")) 539 { 540 settings.LabelAttributes.Add("for", settings.Id); 541 } 542 543 @GetHtmlElement("label", settings.LabelAttributes) 544 if (settings.Control.IsNotNullOrEmpty()) 545 { 546 if (settings.Value.IsNullOrEmpty() && settings.IsRequired) 547 { 548 var checkedAttribute = "checked=\"checked\""; 549 settings.Control = settings.Control.Replace(checkedAttribute, string.Empty); 550 } 551 @settings.Control 552 } 553 else 554 { 555 @GetHtmlElement("input", GetAttributes(settings), true) 556 } 557 <span> 558 @InternalRenderLabel(settings) 559 </span> 560 @GetHtmlElement("label", true) 561 } 562 else 563 { 564 if (settings.Control.IsNotNullOrEmpty()) 565 { 566 if (settings.Value.IsNullOrEmpty() && settings.IsRequired) 567 { 568 var checkedAttribute = "checked=\"checked\""; 569 settings.Control = settings.Control.Replace(checkedAttribute, string.Empty); 570 } 571 @settings.Control 572 } 573 else 574 { 575 @GetHtmlElement("input", GetAttributes(settings), true) 576 } 577 } 578 579 @InternalRenderFieldFooter(settings) 580 } 581 } 582 583 @helper InternalRenderTextareaField(FieldSettings settings) 584 { 585 if (settings.SystemName.IsNotNullOrEmpty() || settings.Control.IsNotNullOrEmpty()) 586 { 587 settings.Assert(FieldType.Textarea); 588 589 @InternalRenderFieldHeader(settings) 590 591 if (settings.Control.IsNotNullOrEmpty()) 592 { 593 @GetControlWithRequiredClass(settings.IsRequired, settings.Control) 594 } 595 else 596 { 597 if (!settings.Attributes.ContainsKey("rows")) 598 { 599 settings.Attributes.Add("rows", "6"); 600 } 601 if (!settings.Attributes.ContainsKey("cols")) 602 { 603 settings.Attributes.Add("cols", "50"); 604 } 605 @GetHtmlElement("textarea", GetAttributes(settings, false)) 606 @settings.Value 607 @GetHtmlElement("textarea", true) 608 } 609 610 @InternalRenderFieldFooter(settings) 611 } 612 } 613 614 @helper InternalRenderRadioOrCheckboxListField(FieldSettings settings) 615 { 616 if (settings.LoopOptions.Any() || settings.FieldOptionsList.Any() || settings.Control.IsNotNullOrEmpty()) 617 { 618 var optionCount = 0; 619 620 settings.Assert(FieldType.Radio); 621 622 @InternalRenderFieldHeader(settings) 623 624 if (settings.LoopOptions.Any()) 625 { 626 settings.CssClass = settings.Type.ToString().ToLower(); 627 foreach (var option in settings.LoopOptions) 628 { 629 optionCount++; 630 if (settings.Id.IsNullOrEmpty() || settings.Id == settings.SystemName) 631 { 632 settings.Id = settings.SystemName + optionCount; 633 } 634 635 var cssClassList = new List<string> {settings.Type.ToString().ToLower(), settings.CssClass}; 636 var cssClass = string.Join(" ", cssClassList.Where(s => s.IsNotNullOrEmpty())); 637 638 if (!settings.LabelAttributes.ContainsKey("class")) 639 { 640 settings.LabelAttributes.Add("class", cssClass); 641 } 642 else 643 { 644 settings.LabelAttributes["class"] = string.Concat(cssClass, " ", settings.LabelAttributes["class"]); 645 } 646 if (!settings.LabelAttributes.ContainsKey("for")) 647 { 648 settings.LabelAttributes.Add("for", settings.Id); 649 } 650 651 @GetHtmlElement("label", settings.LabelAttributes) 652 @GetHtmlElement("input", GetAttributes(settings), true) 653 <span>@option.GetString(settings.LabelLoopTag)</span> 654 @GetHtmlElement("label", true) 655 } 656 } 657 else if (settings.FieldOptionsList.Any()) 658 { 659 foreach (var option in settings.FieldOptionsList) 660 { 661 optionCount++; 662 663 if (option.SystemName.IsNullOrEmpty()) 664 { 665 option.SystemName = settings.SystemName; 666 } 667 if (option.Id.IsNullOrEmpty() || option.Id == option.SystemName) 668 { 669 option.Id = option.SystemName + optionCount; 670 } 671 var cssClassList = new List<string> {settings.Type.ToString().ToLower(), option.CssClass}; 672 var cssClass = string.Join(" ", cssClassList.Where(s => s.IsNotNullOrEmpty())); 673 674 if (!option.LabelAttributes.ContainsKey("class")) 675 { 676 option.LabelAttributes.Add("class", cssClass); 677 } 678 else 679 { 680 option.LabelAttributes["class"] = string.Concat(cssClass, " ", option.LabelAttributes["class"]); 681 } 682 if (!option.LabelAttributes.ContainsKey("for")) 683 { 684 option.LabelAttributes.Add("for", option.Id); 685 } 686 687 @GetHtmlElement("label", option.LabelAttributes) 688 @InternalRenderInputOptionField("input", option, settings.Type) 689 <span>@option.Label</span> 690 @GetHtmlElement("label", true) 691 } 692 } 693 else if (settings.Control.IsNotNullOrEmpty()) 694 { 695 @settings.Control 696 } 697 698 @InternalRenderFieldFooter(settings) 699 } 700 } 701 702 @helper InternalRenderInputField(FieldSettings settings) 703 { 704 if (settings.SystemName.IsNotNullOrEmpty() || settings.Control.IsNotNullOrEmpty()) 705 { 706 settings.Assert(FieldType.Text); 707 708 @InternalRenderFieldHeader(settings) 709 710 if (settings.Control.IsNotNullOrEmpty()) 711 { 712 var type = settings.Type.ToString().ToLower(); 713 if (settings.Type == FieldType.DatetimeLocal) 714 { 715 type = "datetime-local"; 716 } 717 718 if (settings.Type == FieldType.Password) 719 { 720 settings.Control = settings.Control.Replace("input ", "input autocomplete=\"off\" "); 721 } 722 @GetControlWithRequiredClass(settings.IsRequired, settings.Control) 723 } 724 else 725 { 726 if (settings.Type == FieldType.Password && !settings.Attributes.ContainsKey("autocomplete")) 727 { 728 settings.Attributes.Add("autocomplete", "off"); 729 } 730 @GetHtmlElement("input", GetAttributes(settings), true) 731 } 732 733 @InternalRenderFieldFooter(settings) 734 } 735 } 736 737 @helper InternalRenderDateTimeField(FieldSettings settings) 738 { 739 if (settings.SystemName.IsNotNullOrEmpty() || settings.Control.IsNotNullOrEmpty()) 740 { 741 settings.Assert(FieldType.Datetime); 742 settings.Attributes = new Dictionary<string, string> 743 { 744 {"placeholder", "&#xf073;"} 745 }; 746 747 @InternalRenderFieldHeader(settings) 748 749 if (settings.Control.IsNotNullOrEmpty()) 750 { 751 var type = settings.Type.ToString().ToLower(); 752 753 settings.Control = settings.Control.Replace("type=\"text\"", "type=\"" + type + "\""); 754 @GetControlWithRequiredClass(settings.IsRequired, settings.Control) 755 } 756 else 757 { 758 @GetHtmlElement("input", GetAttributes(settings), true) 759 } 760 761 @InternalRenderFieldFooter(settings) 762 } 763 } 764 765 @helper InternalRenderSelectField(FieldSettings settings) 766 { 767 const int limit = 10; 768 769 settings.Assert(FieldType.Select); 770 771 if (settings.CssClass.ToLower().Contains("country")) 772 { 773 @RenderCountriesDropdownField(settings, true, settings.CssClass.ToLower().Contains("highlights")) 774 } 775 else 776 { 777 if (settings.SystemName.IsNotNullOrEmpty() || settings.Control.IsNotNullOrEmpty() || settings.FieldOptionsList.Any() || settings.ValuesList.Any()) 778 { 779 @InternalRenderFieldHeader(settings) 780 781 int optionsCount; 782 if (settings.Control.IsNotNullOrEmpty()) 783 { 784 optionsCount = Regex.Matches(settings.Control, "option ").Count; 785 786 if (optionsCount > limit || optionsCount == 0) 787 { 788 settings.Control = settings.Control.Replace("select ", "select data-live-search=\"true\" "); 789 } 790 @GetControlWithRequiredClass(settings.IsRequired, settings.Control, settings.CssClass) 791 } 792 else 793 { 794 optionsCount = settings.FieldOptionsList.Count + settings.ValuesList.Count; 795 796 if (!settings.Attributes.ContainsKey("multiple") && !settings.Attributes.ContainsKey("data-live-search") && (optionsCount > limit || optionsCount == 0)) 797 { 798 settings.Attributes.Add("data-live-search", "true"); 799 } 800 @GetHtmlElement("select", GetAttributes(settings, false)) 801 802 if (settings.FirstHardcodedOptionLabel.IsNotNullOrEmpty()) 803 { 804 @InternalRenderOption(FieldOption.CreateOption(settings.FirstHardcodedOptionLabel, settings.FirstHardcodedOptionValue, settings.IsFirstHardcodedOptionSelected)) 805 } 806 807 foreach (var option in settings.FieldOptionsList) 808 { 809 @InternalRenderOption(option) 810 } 811 foreach (var option in settings.ValuesList) 812 { 813 @InternalRenderOption(FieldOption.CreateOption(option, option)) 814 } 815 816 @GetHtmlElement("select", true) 817 } 818 819 @InternalRenderFieldFooter(settings) 820 } 821 } 822 } 823 824 @helper InternalRenderButtonField(FieldSettings settings) 825 { 826 settings.Assert(FieldType.Button); 827 828 @InternalRenderFieldHeader(settings, false) 829 830 if (settings.Control.IsNotNullOrEmpty()) 831 { 832 var controlOutput = settings.Control; 833 switch (settings.Type) 834 { 835 case FieldType.Submit: 836 controlOutput = controlOutput.Replace("input ", "input class='btn btn-default'"); 837 break; 838 case FieldType.Reset: 839 controlOutput = controlOutput.Replace("input ", "input class='btn btn-bg2'"); 840 break; 841 case FieldType.Button: 842 case FieldType.Textarea: 843 case FieldType.File: 844 case FieldType.Text: 845 case FieldType.Hidden: 846 case FieldType.Radio: 847 case FieldType.Checkbox: 848 case FieldType.Select: 849 case FieldType.Checkboxlist: 850 case FieldType.Divider: 851 case FieldType.Image: 852 case FieldType.Password: 853 case FieldType.Textstring: 854 case FieldType.Search: 855 case FieldType.Email: 856 case FieldType.Url: 857 case FieldType.Tel: 858 case FieldType.Number: 859 case FieldType.Range: 860 case FieldType.Date: 861 case FieldType.Month: 862 case FieldType.Week: 863 case FieldType.Time: 864 case FieldType.Datetime: 865 case FieldType.DatetimeLocal: 866 case FieldType.Color: 867 case FieldType.Unknown: 868 default: 869 throw new NotSupportedException(string.Format("Unsupported Field Type: {0}.", settings.Type.ToString())); 870 } 871 @controlOutput 872 } 873 else 874 { 875 settings.CssClass = settings.CssClass.IsNullOrEmpty() ? "btn btn-default" : "btn " + settings.CssClass; 876 if (settings.Type == FieldType.Button) 877 { 878 if (settings.Label.IsNullOrEmpty()) 879 { 880 settings.Label = Translate("Button"); 881 } 882 @GetHtmlElement("button", GetAttributes(settings)) 883 @InternalRenderLabel(settings) 884 @GetHtmlElement("button", true) 885 } 886 else 887 { 888 @GetHtmlElement("input", GetAttributes(settings), true) 889 } 890 } 891 892 @InternalRenderFieldFooter(settings) 893 } 894 895 896 @* Forms for Editors field types in enum FieldType *@ 897 @helper InternalRenderTextStringField(FieldSettings settings) 898 { 899 settings.Assert(FieldType.Textstring); 900 901 if (settings.Description.IsNotNullOrEmpty() || settings.Control.IsNotNullOrEmpty()) 902 { 903 if (settings.Control.IsNotNullOrEmpty()) 904 { 905 @settings.Control 906 } 907 else 908 { 909 <p class="help-block">@settings.Description</p> 910 } 911 } 912 } 913 914 @helper InternalRenderImageField(FieldSettings settings) 915 { 916 settings.Assert(FieldType.Image); 917 918 if (settings.Control.IsNotNullOrEmpty()) 919 { 920 @settings.Control 921 } 922 } 923 924 @helper InternalRenderDividerField(FieldSettings settings) 925 { 926 settings.Assert(FieldType.Divider); 927 928 <hr class="divider" /> 929 } 930 931 @helper InternalRenderInputOptionField(string htmlElement, FieldOption optionSettings, FieldType type = FieldType.Radio) 932 { 933 var fieldType = type == FieldType.Checkboxlist ? FieldType.Checkbox.ToString().ToLower() : type.ToString().ToLower(); 934 var attributes = new StringBuilder(GetAttribute("type", fieldType)); 935 attributes.Append(GetAttribute("value", optionSettings.Value)); 936 attributes.Append(GetAttribute("name", optionSettings.SystemName)); 937 attributes.Append(optionSettings.Id.IsNotNullOrEmpty() ? GetAttribute("id", optionSettings.Id) : optionSettings.SystemName); 938 attributes.Append(GetAttributes(optionSettings.Attributes)); 939 940 if (optionSettings.IsSelected) 941 { 942 attributes.Append(GetAttribute("checked", "checked")); 943 } 944 if (optionSettings.IsDisabled) 945 { 946 attributes.Append(GetAttribute("disabled", "disabled")); 947 } 948 949 @GetHtmlElement(htmlElement, attributes.ToString()) 950 } 951 952 @helper InternalRenderOption(FieldOption optionSettings) 953 { 954 var selected = optionSettings.IsSelected ? " selected" : string.Empty; 955 var disabled = optionSettings.IsDisabled ? " disabled" : string.Empty; 956 var readOnly = optionSettings.IsReadOnly ? " readonly" : string.Empty; 957 var attributes = GetAttributes(optionSettings); 958 959 @GetHtmlElement("option", attributes + selected + disabled + readOnly) 960 @InternalRenderLabel(optionSettings.Label, optionSettings.TranslateKeyForLabel) 961 @GetHtmlElement("option", true) 962 } 963 964 @helper InternalRenderFieldHeader(FieldSettings settings, bool renderLabel = true) 965 { 966 @GetWrapperStart(settings.IncludeWrapper, settings.Type, settings.WrapperElement, settings.IsRequired, settings.WrapperCssClass) 967 if ((settings.Label.IsNotNullOrEmpty() || settings.TranslateKeyForLabel.IsNotNullOrEmpty()) && renderLabel) 968 { 969 var attributes = new Dictionary<string, string> 970 { 971 {"class", GetAttributeString("form-label", settings.LabelCssClass)} 972 }; 973 974 if (settings.Type != FieldType.Checkboxlist && settings.Type != FieldType.Radio) 975 { 976 attributes.Add("for", settings.SystemName); 977 } 978 979 @GetHtmlElement("label", attributes) 980 @InternalRenderLabel(settings) 981 @GetHtmlElement("label", true) 982 } 983 if (settings.Prepend.IsNotNullOrEmpty()) 984 { 985 var attributes = new Dictionary<string, string> 986 { 987 {"class", "fieldPrepend input-group-addon"} 988 }; 989 @GetHtmlElement("div", attributes) 990 @settings.Prepend 991 @GetHtmlElement("div", true) 992 } 993 if (settings.IncludeFieldWrapper) 994 { 995 @:<div class="fieldContainer hidden @settings.FieldWrapperCssClass"> 996 } 997 } 998 999 @helper InternalRenderFieldFooter(FieldSettings settings) 1000 { 1001 if (settings.Icon.IsNotNullOrEmpty()) 1002 { 1003 @RenderIcon(settings.Icon, settings.Tooltip, IconPosition.Left, true) 1004 } 1005 if (settings.Append.IsNotNullOrEmpty()) 1006 { 1007 <div class="fieldAppend input-group-addon">@settings.Append</div> 1008 } 1009 if (settings.Description.IsNotNullOrEmpty()) 1010 { 1011 <p class="help-block">@settings.Description</p> 1012 } 1013 if (settings.IncludeFieldWrapper) 1014 { 1015 @:</div> 1016 } 1017 @GetWrapperEnd(settings.IncludeWrapper, settings.WrapperElement) 1018 } 1019 1020 @helper InternalRenderQuantityField(int productStock, int productAvailableAmount, int selectedQuantity = 1, int productType = 0) 1021 { 1022 @InternalRenderQuantityField(productStock, productAvailableAmount, selectedQuantity, string.Empty, 10, false, false, productType) 1023 } 1024 1025 @helper InternalRenderQuantityField(int productStock, int productAvailableAmount, int selectedQuantity = 1, bool variantGroupsExistList = false) 1026 { 1027 @InternalRenderQuantityField(productStock, productAvailableAmount, selectedQuantity, string.Empty, 10, false, variantGroupsExistList) 1028 } 1029 1030 @helper InternalRenderQuantityField(int productStock, int productAvailableAmount, int selectedQuantity = 1, string fieldSystemName = "", int limit = 10, bool isCheckout = true, bool variantGroupsExistList = false, int productType = 0, string productId = "") 1031 { 1032 var isQuantityTextHidden = selectedQuantity < 10 && productStock > 0 || !isCheckout ? " hidden" : string.Empty; 1033 var isSelectDisabled = productStock <= 0 && !isCheckout; 1034 var quantityTextFieldSettings = new FieldSettings 1035 { 1036 Value = selectedQuantity.ToString(), 1037 SystemName = fieldSystemName.IsNullOrEmpty() ? "quantity" : fieldSystemName, 1038 Id = (fieldSystemName.IsNullOrEmpty() ? "quantity_" : fieldSystemName) + productId, 1039 Attributes = new Dictionary<string, string> 1040 { 1041 {"maxlength", "5"}, 1042 {"data-productStock", productStock.ToString()}, 1043 {"data-productAvailable", productAvailableAmount.ToString()}, 1044 {"data-outofstock", Translate("Out of stock")}, 1045 {"data-stocktranslate", Translate("The current stock is")}, 1046 {"data-currentValue", selectedQuantity.ToString()} 1047 } 1048 }; 1049 1050 if (productType != 1 && productType != 3) 1051 { 1052 quantityTextFieldSettings.Type = FieldType.Number; 1053 quantityTextFieldSettings.Label = Translate("Qty"); 1054 quantityTextFieldSettings.CssClass = "col-xs-4 col-sm-7 quantityInput" + isQuantityTextHidden; 1055 quantityTextFieldSettings.LabelCssClass = productStock > 0 ? "" : "hidden"; 1056 quantityTextFieldSettings.Attributes.Add("min", "1"); 1057 quantityTextFieldSettings.Attributes.Add("onblur", "checkMinValue(this);"); 1058 1059 <fieldset class="quantity-container pull-left"> 1060 @if (isCheckout) 1061 { 1062 <div class="@isQuantityTextHidden quantityPriceContainer"> 1063 @RenderField(quantityTextFieldSettings) 1064 @RenderBootstrapButton(new BootstrapButtonSettings {IconCssClass = "fa-refresh", CssClass = "submitQuantity btnCart-blue", ButtonType = BootstrapButtonSettings.BootstrapButtonType.Button}) 1065 </div> 1066 } 1067 else 1068 { 1069 @RenderField(quantityTextFieldSettings) 1070 } 1071 1072 @if (selectedQuantity < limit) 1073 { 1074 var quantityOptionLimit = productStock <= 0 ? 10 : productStock >= limit || variantGroupsExistList ? limit : productStock + 1; 1075 var quantityFieldSettings = new FieldSettings 1076 { 1077 Type = FieldType.Select, 1078 SystemName = "quantitySelect", 1079 Id = "quantitySelect" + productId 1080 }; 1081 if (isSelectDisabled) 1082 { 1083 quantityFieldSettings.Attributes.Add("disabled", "disabled"); 1084 } 1085 1086 for (var num = 1; num < quantityOptionLimit; num++) 1087 { 1088 var cssClass = num >= quantityOptionLimit ? "hidden" : ""; 1089 quantityFieldSettings.FieldOptionsList.Add(new FieldOption {Label = num.ToString(), Value = num.ToString(), IsSelected = selectedQuantity == num, CssClass = cssClass}); 1090 } 1091 1092 if (productStock >= limit || variantGroupsExistList) 1093 { 1094 var limitPlus = limit + "+"; 1095 var cssClass = variantGroupsExistList && productStock < limit ? "hidden" : ""; 1096 quantityFieldSettings.FieldOptionsList.Add(new FieldOption {Label = limitPlus, Value = limitPlus, CssClass = cssClass}); 1097 } 1098 @RenderField(quantityFieldSettings) 1099 } 1100 </fieldset> 1101 } 1102 else 1103 { 1104 quantityTextFieldSettings.Type = FieldType.Hidden; 1105 @RenderField(quantityTextFieldSettings) 1106 } 1107 } 1108 1109 @* Countries and Regions helpers *@ 1110 @helper InternalRenderCountryAndRegionsJsVariables(Dynamicweb.Ecommerce.International.CountryCollection countries = null) 1111 { 1112 if (countries == null) 1113 { 1114 countries = Dynamicweb.Ecommerce.Services.Countries.GetCountries(); 1115 } 1116 1117 if (countries.Any()) 1118 { 1119 @: @SnippetStart("jsVariables") var countryRegions = {}; @SnippetEnd("jsVariables") 1120 1121 foreach (var country in countries.OrderBy(s => s.Name)) 1122 { 1123 var regions = Dynamicweb.Ecommerce.Services.Countries.GetRegions(country.Code2); 1124 1125 if (regions.Any()) 1126 { 1127 @: @SnippetStart("jsVariables") countryRegions.@( country.Code2) = {}; @SnippetEnd("jsVariables") 1128 <text> 1129 @SnippetStart("jsVariables") 1130 countryRegions.@( country.Code2).code = []; 1131 countryRegions.@( country.Code2).name = []; 1132 @SnippetEnd("jsVariables") 1133 </text> 1134 foreach (var region in regions.OrderBy(s => s.Name)) 1135 { 1136 <text> 1137 @SnippetStart("jsVariables") 1138 countryRegions["@country.Code2"].code.push("@region.RegionCode"); 1139 countryRegions["@country.Code2"].name.push("@region.Name"); 1140 @SnippetEnd("jsVariables") 1141 </text> 1142 } 1143 } 1144 } 1145 } 1146 } 1147 1148 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 1149 @using Dynamicweb.Rendering 1150 @functions 1151 { 1152 public static bool IsBillingAddressReadOnly() 1153 { 1154 return Dna.Modules.Features.FeatureManager.IsEnabled("IsBillingAddressReadOnly", "Set to 'true' if the Billing Address should be read-only."); 1155 } 1156 1157 public static bool IsBillingAddressEditable() 1158 { 1159 return Dna.Modules.Features.FeatureManager.IsEnabled("IsBillingAddressEditable", "Set to 'true' if the Billing Address should be editable."); 1160 } 1161 1162 public static bool IsShippingAddressEditable() 1163 { 1164 return Dna.Modules.Features.FeatureManager.IsEnabled("IsShippingAddressEditable", "Set to 'true' if the Shipping Address should be editable."); 1165 } 1166 1167 public static bool ShowNoErpConnectionMessage() 1168 { 1169 return Dna.Modules.Features.FeatureManager.IsEnabled("showNoErpConnectionMessage", "Set to 'true' if want to show the 'No ERP Connection Message'."); 1170 } 1171 1172 public static bool ShowStateFieldAsDropdown() 1173 { 1174 return Dna.Modules.Features.FeatureManager.IsEnabled("showStateFieldAsDropdown", "Set to 'true' if the State field should be a drop-down."); 1175 } 1176 public static bool ShowVariantsAsDropdown() 1177 { 1178 return Dna.Modules.Features.FeatureManager.IsEnabled("showVariantsAsDropdown", "Set to 'true' if the Variant field should be a drop-down."); 1179 } 1180 public static bool ShowB2BLogin() 1181 { 1182 return Dna.Modules.Features.FeatureManager.IsEnabled("showB2BLogin", "Set to 'true' if it should display a login page."); 1183 } 1184 public static bool ShowRatings() 1185 { 1186 return Dna.Modules.Features.FeatureManager.IsEnabled("showRatrings", "Set to 'true' if ratings should be displayed."); 1187 } 1188 public static bool ShowReviews() 1189 { 1190 return Dna.Modules.Features.FeatureManager.IsEnabled("showReviews", "Set to 'true' if reviews should be displayed."); 1191 } 1192 1193 public static bool ShowRatingInProductList() 1194 { 1195 return Dna.Modules.Features.FeatureManager.IsEnabled("showRatingInProductList", "Set to 'true' if ratings in product list should be displayed."); 1196 } 1197 } 1198 @functions{ 1199 1200 #region Css functions 1201 1202 public static string GetPalletColorNumber(int number = 0) 1203 { 1204 switch (number) 1205 { 1206 case 1: 1207 return "#666666"; 1208 case 2: 1209 return "#092138"; 1210 default: 1211 return "#ffffff"; 1212 } 1213 } 1214 1215 public static string GetFontFamilyNumber(int number = 0) 1216 { 1217 switch (number) 1218 { 1219 case 1: 1220 return "font-family: Arial, sans-serif;"; 1221 default: 1222 return "font-family: Helvetica, Arial, sans-serif;"; 1223 } 1224 } 1225 1226 public static string GetFontSize(int fontSize = 0) 1227 { 1228 return fontSize >= 0 ? string.Concat("font-size: ", fontSize, "px;") : "font-size: 14px"; 1229 } 1230 1231 #endregion Css functions 1232 1233 #region Icon functions 1234 1235 public static string GetIcon(string cssPartialClass, string label = "", string position = "") 1236 { 1237 var icon = "<i class='fa " + cssPartialClass + "'></i>"; 1238 var spacing = string.Empty; 1239 1240 if (!label.IsNullOrEmpty()) 1241 { 1242 spacing = "&nbsp;"; 1243 } 1244 1245 if (cssPartialClass.IsNullOrEmpty()) return label; 1246 if (position == IconPosition.Left.ToString() || position.IsNullOrEmpty()) 1247 { 1248 return icon + spacing + label; 1249 } 1250 return label + spacing + icon; 1251 } 1252 1253 #endregion Icon functions 1254 1255 #region Address functions 1256 1257 public string GetAddressFormatted(User user, bool getRegionName = false, bool getCountryName = false, bool addLineBreakBetweenAddressAndCity = false, string splitBetweenRegionAndCountry = " ") 1258 { 1259 return GetAddressFormatted(user.Address, user.Address2, user.City, user.State, user.Zip, user.Country, getRegionName, getCountryName, addLineBreakBetweenAddressAndCity, splitBetweenRegionAndCountry); 1260 } 1261 1262 public string GetAddressFormatted(UserAddress userAddress, bool getRegionName = false, bool getCountryName = false, bool addLineBreakBetweenAddressAndCity = false, string splitBetweenRegionAndCountry = " ") 1263 { 1264 return GetAddressFormatted(userAddress.Address, userAddress.Address2, userAddress.City, userAddress.State, userAddress.Zip, userAddress.Country, getRegionName, getCountryName, addLineBreakBetweenAddressAndCity, splitBetweenRegionAndCountry); 1265 } 1266 1267 public string GetAddressFormatted(AddressSource addressSource, bool getRegionName = false, bool getCountryName = false, bool addLineBreakBetweenAddressAndCity = false, string splitBetweenRegionAndCountry = " ") 1268 { 1269 switch (addressSource) 1270 { 1271 case AddressSource.UserProfile: 1272 return GetAddressFormatted( 1273 GetString("UserManagement:User.Address"), 1274 GetString("UserManagement:User.Address2"), 1275 GetString("UserManagement:User.City"), 1276 GetString("UserManagement:User.State"), 1277 GetString("UserManagement:User.Zip"), 1278 GetString("UserManagement:User.Country"), 1279 getRegionName, 1280 getCountryName, 1281 addLineBreakBetweenAddressAndCity, 1282 splitBetweenRegionAndCountry 1283 ); 1284 case AddressSource.EcomCustomer: 1285 return GetAddressFormatted( 1286 GetString("Ecom:Order.Customer.Address"), 1287 GetString("Ecom:Order.Customer.Address2"), 1288 GetString("Ecom:Order.Customer.City"), 1289 GetString("Ecom:Order.Customer.Region"), 1290 GetString("Ecom:Order.Customer.Zip"), 1291 GetString("Ecom:Order.Customer.Country"), 1292 getRegionName, 1293 getCountryName, 1294 addLineBreakBetweenAddressAndCity, 1295 splitBetweenRegionAndCountry 1296 ); 1297 case AddressSource.EcomDelivery: 1298 return GetAddressFormatted( 1299 GetString("Ecom:Order.Delivery.Address"), 1300 GetString("Ecom:Order.Delivery.Address2"), 1301 GetString("Ecom:Order.Delivery.City"), 1302 GetString("Ecom:Order.Delivery.Region"), 1303 GetString("Ecom:Order.Delivery.Zip"), 1304 GetString("Ecom:Order.Delivery.Country"), 1305 getRegionName, 1306 getCountryName, 1307 addLineBreakBetweenAddressAndCity, 1308 splitBetweenRegionAndCountry 1309 ); 1310 case AddressSource.UserAddress: 1311 throw new NotImplementedException("Not applicable"); 1312 default: 1313 throw new ArgumentOutOfRangeException("addressSource property", addressSource, null); 1314 } 1315 } 1316 1317 public string GetAddressFormatted(string address, string address2, string city, string zip, string region, string country, bool getRegionName = false, bool getCountryName = false, bool addLineBreakBetweenAddressAndCity = false, string splitBetweenRegionAndCountry = " ") 1318 { 1319 var formattedAddress = new StringBuilder(address); 1320 1321 if (address2.IsNotNullOrEmpty()) 1322 { 1323 formattedAddress.Append(string.Concat(" ",address2)); 1324 } 1325 if (addLineBreakBetweenAddressAndCity && (city + region + country).IsNotNullOrEmpty()) 1326 { 1327 formattedAddress.Append("<br/>"); 1328 } 1329 if (city.IsNotNullOrEmpty()) 1330 { 1331 formattedAddress.Append(string.Concat(" ",city)); 1332 } 1333 if (zip.IsNotNullOrEmpty()) 1334 { 1335 formattedAddress.Append(string.Concat(" ",zip)); 1336 } 1337 if (region.IsNotNullOrEmpty()) 1338 { 1339 formattedAddress.Append(zip.IsNotNullOrEmpty() ? string.Empty : ","); 1340 if (getRegionName && country.IsNotNullOrEmpty()) 1341 { 1342 var getRegions = Services.Countries.GetRegions(country); 1343 if(getRegions != null) { 1344 var regionName = getRegions.First(c => c.RegionCode == region).Name; 1345 region = regionName.IsNotNullOrEmpty() ? regionName : region; 1346 } 1347 } 1348 formattedAddress.Append(string.Concat(" ",region)); 1349 } 1350 1351 if (country.IsNullOrEmpty()) 1352 { 1353 return formattedAddress.ToString(); 1354 } 1355 1356 formattedAddress.Append(splitBetweenRegionAndCountry.IsNotNullOrEmpty() ? splitBetweenRegionAndCountry : " "); 1357 if (getCountryName) 1358 { 1359 var getCountry = Services.Countries.GetCountry(country); 1360 if(getCountry != null) 1361 { 1362 var countryName = getCountry.Name; 1363 country = countryName.IsNotNullOrEmpty() ? countryName : country; 1364 } 1365 } 1366 formattedAddress.Append(country); 1367 1368 return formattedAddress.ToString(); 1369 } 1370 1371 #endregion Address functions 1372 1373 #region Field helper functions 1374 1375 const string HighlightedCountriesSplit = "----------------"; 1376 1377 internal readonly List<string> HighlightedCountries = new List<string> 1378 { 1379 "CA", 1380 "US", 1381 HighlightedCountriesSplit 1382 }; 1383 1384 #endregion Field helper functions 1385 1386 #region Generic functions 1387 1388 private static int FormatInteger(object value) 1389 { 1390 int num; 1391 if (value == null) 1392 { 1393 value = string.Empty; 1394 } 1395 return int.TryParse(value.ToString(), out num) ? num : 0; 1396 } 1397 1398 #endregion Generic functions 1399 } 1400 @{ 1401 @* Tables and list helpers *@ 1402 @helper RenderTableHeading(string label, string sortByField = "", string listType = "Order") 1403 { 1404 if (sortByField.IsNotNullOrEmpty()) 1405 { 1406 var href = string.Empty; 1407 var icon = "fa-sort-amount-asc"; 1408 var sortOrder = "asc"; 1409 1410 if (listType == "Order" || listType == "Rma") 1411 { 1412 href = GetCustomerCenterSortUrl(sortByField, listType); 1413 if (GetSortFieldParameter("name") == sortByField) 1414 { 1415 sortOrder = GetSortFieldParameter("value", sortByField).ToLower(); 1416 icon = "fa-sort-amount-" + sortOrder; 1417 1418 } 1419 } 1420 else if (listType == "DataList") 1421 { 1422 var sortByParameter = Sanitize.Parameter("sortby").IsNotNullOrEmpty() ? Sanitize.Parameter("sortby") : string.Empty; 1423 var sortOrderParameter = Sanitize.Parameter("sortorder").IsNotNullOrEmpty() ? Sanitize.Parameter("sortorder") : "ASC"; 1424 1425 href = GetDataListSortUrl(sortByField); 1426 if (sortByParameter == sortByField) 1427 { 1428 sortOrder = sortOrderParameter.ToLower(); 1429 icon = "fa-sort-amount-" + sortOrder; 1430 sortOrder = sortOrder == "asc" ? "desc" : "asc"; 1431 } 1432 } 1433 <a href="@href" data-sortby="@sortByField" data-sortorder="@sortOrder.ToUpperInvariant()"> 1434 @RenderIcon(icon, label, IconPosition.Right) 1435 </a> 1436 } 1437 else 1438 { 1439 @label 1440 } 1441 } 1442 1443 @helper RenderDataListItem(string label, string value, string labelCss = "col-xs-4 text-right", string valueCss = "col-xs-8", string alternativeValue = "", bool isLabelBold = true) 1444 { 1445 if (value.IsNotNullOrEmpty() || alternativeValue.IsNotNullOrEmpty()) 1446 { 1447 var displayValue = alternativeValue.IsNullOrEmpty() ? value : alternativeValue; 1448 1449 <dt class="@labelCss"> 1450 @if (isLabelBold) 1451 { 1452 @: <strong> 1453 } 1454 @label 1455 @if (isLabelBold) 1456 { 1457 @: </strong> 1458 } 1459 </dt> 1460 <dd class="@valueCss"> 1461 @displayValue 1462 </dd> 1463 } 1464 } 1465 1466 @helper RenderTableRowSpacer(int height = 30, int colspan = 1) 1467 { 1468 if (height == 0) 1469 { 1470 height = 30; 1471 } 1472 1473 <tr> 1474 @if (colspan > 1) 1475 { 1476 @: <td colspan="@colspan" height="@height"></td> 1477 } 1478 else 1479 { 1480 <td height="@height"></td> 1481 } 1482 </tr> 1483 } 1484 1485 @helper RenderTableCellSpacer(int width = 10, int height = 10) 1486 { 1487 if (width == 0) 1488 { 1489 width = 10; 1490 } 1491 if (height == 0) 1492 { 1493 height = 10; 1494 } 1495 <td width="@width" height="@height">&nbsp;</td> 1496 } 1497 1498 1499 @* Tab helpers *@ 1500 @helper RenderTabContent(string tabKey, string tabLabel, string tabContent, string cssClass = "") 1501 { 1502 if (tabContent.IsNotNullOrEmpty()) 1503 { 1504 @InternalRenderTabHeader("#" + tabKey, tabLabel, cssClass) 1505 <div class="col-xs-12 @cssClass" id="@tabKey"> 1506 @tabContent 1507 </div> 1508 } 1509 } 1510 1511 1512 @* Field helpers *@ 1513 @helper RenderField(FieldSettings settings) 1514 { 1515 switch (settings.Type) 1516 { 1517 case FieldType.Button: 1518 case FieldType.Reset: 1519 case FieldType.Submit: 1520 @InternalRenderButtonField(settings) 1521 break; 1522 case FieldType.Checkbox: 1523 @InternalRenderCheckboxField(settings) 1524 break; 1525 case FieldType.Image: 1526 @InternalRenderImageField(settings) 1527 break; 1528 case FieldType.Checkboxlist: 1529 case FieldType.Radio: 1530 @InternalRenderRadioOrCheckboxListField(settings) 1531 break; 1532 case FieldType.Select: 1533 @InternalRenderSelectField(settings) 1534 break; 1535 case FieldType.Color: 1536 case FieldType.Date: 1537 case FieldType.DatetimeLocal: 1538 case FieldType.Email: 1539 case FieldType.File: 1540 case FieldType.Hidden: 1541 case FieldType.Password: 1542 case FieldType.Month: 1543 case FieldType.Number: 1544 case FieldType.Range: 1545 case FieldType.Search: 1546 case FieldType.Tel: 1547 case FieldType.Text: 1548 case FieldType.Time: 1549 case FieldType.Url: 1550 case FieldType.Week: 1551 @InternalRenderInputField(settings) 1552 break; 1553 case FieldType.Textarea: 1554 @InternalRenderTextareaField(settings) 1555 break; 1556 case FieldType.Textstring: 1557 @InternalRenderTextStringField(settings) 1558 break; 1559 case FieldType.Divider: 1560 @InternalRenderDividerField(settings) 1561 break; 1562 case FieldType.Datetime: 1563 @InternalRenderDateTimeField(settings) 1564 break; 1565 case FieldType.Unknown: 1566 @:<div style="color: #f00">Undefined FieldType: <strong>@settings.Type</strong></div> 1567 break; 1568 default: 1569 throw new NotSupportedException(string.Format("Unsupported Field Type: {0}.", settings.Type.ToString())); 1570 } 1571 } 1572 1573 @helper RenderCountriesDropdownField(List<string> countries, bool renderJsVariables = true, bool renderHighlightOptions = true, bool isFirstHardcodedOptionDisabled = true) 1574 { 1575 var settings = new FieldSettings 1576 { 1577 SystemName = "country", 1578 Id = "country", 1579 Label = Translate("Select your country:"), 1580 FirstHardcodedOptionLabel = Translate("All"), 1581 ValuesList = countries 1582 }; 1583 @RenderCountriesDropdownField(settings, renderJsVariables, renderHighlightOptions, isFirstHardcodedOptionDisabled) 1584 } 1585 1586 @helper RenderCountriesDropdownField(FieldSettings settings, bool renderJsVariables = true, bool renderHighlightOptions = true, bool isFirstHardcodedOptionDisabled = true) 1587 { 1588 1589 if (settings.SystemName.IsNotNullOrEmpty()) 1590 { 1591 const int limit = 10; 1592 const int numOfCountriesForHighlight = 10; 1593 var countries = EcommerceHelpers.GetEcomCountries(); 1594 var numOfCountries = settings.LoopOptions.Any() ? settings.LoopOptions.Count : settings.ValuesList.Any() ? settings.ValuesList.Count : countries.Count; 1595 1596 settings.Assert(FieldType.Select); 1597 if (settings.FirstHardcodedOptionLabel.IsNullOrEmpty()) 1598 { 1599 settings.FirstHardcodedOptionLabel = Translate("Select an option"); 1600 } 1601 if (!settings.Attributes.ContainsKey("multiple") && !settings.Attributes.ContainsKey("data-live-search") && numOfCountries > limit) 1602 { 1603 settings.Attributes.Add("data-live-search", "true"); 1604 } 1605 1606 if (renderJsVariables) 1607 { 1608 @InternalRenderCountryAndRegionsJsVariables(countries) 1609 } 1610 1611 @InternalRenderFieldHeader(settings) 1612 @GetHtmlElement("select", GetAttributes(settings)) 1613 @InternalRenderOption(FieldOption.CreateOption(settings.FirstHardcodedOptionLabel, settings.FirstHardcodedOptionValue, settings.IsFirstHardcodedOptionSelected, isFirstHardcodedOptionDisabled)) 1614 1615 1616 if (numOfCountries > numOfCountriesForHighlight) 1617 { 1618 @RenderSnippet("highlightedContries") 1619 } 1620 1621 if (settings.LoopOptions.Any()) 1622 { 1623 1624 foreach (var country in settings.LoopOptions) 1625 { 1626 var countryName = country.GetString("Ecom:Country.Name"); 1627 var countryCode = country.GetString("Ecom:Country.Code2"); 1628 1629 if (renderHighlightOptions && HighlightedCountries.Any(c => c.Equals(countryCode, StringComparison.CurrentCultureIgnoreCase))) 1630 { 1631 @PopulateHighlightedCountries(countryName, countryCode) 1632 } 1633 else 1634 { 1635 @InternalRenderOption(FieldOption.CreateOption(countryName, countryCode)) 1636 } 1637 1638 } 1639 } 1640 else if (settings.ValuesList.Any()) 1641 { 1642 foreach (var countryCode in settings.ValuesList.OrderBy(s => s)) 1643 { 1644 var countryName = countries.Any(c => c.Code2 == countryCode) ? countries.First(c => c.Code2 == countryCode).Name : countryCode; 1645 1646 if (renderHighlightOptions && HighlightedCountries.Any(c => c.Equals(countryCode, StringComparison.CurrentCultureIgnoreCase))) 1647 { 1648 @PopulateHighlightedCountries(countryName, countryCode) 1649 } 1650 else 1651 { 1652 @InternalRenderOption(FieldOption.CreateOption(countryName, countryCode)) 1653 } 1654 1655 } 1656 } 1657 else 1658 { 1659 foreach (var country in countries.OrderBy(s => s.Name)) 1660 { 1661 var countryCode = country.Code2; 1662 1663 if (renderHighlightOptions && HighlightedCountries.Any(c => c.Equals(countryCode, StringComparison.CurrentCultureIgnoreCase))) 1664 { 1665 @PopulateHighlightedCountries(country.Name, countryCode) 1666 } 1667 else 1668 { 1669 @InternalRenderOption(FieldOption.CreateOption(country.Name, countryCode)) 1670 } 1671 1672 } 1673 } 1674 1675 if (renderHighlightOptions && numOfCountries > numOfCountriesForHighlight && HighlightedCountries.Any(c => HighlightedCountriesSplit.Equals(c, StringComparison.CurrentCultureIgnoreCase))) 1676 { 1677 @PopulateHighlightedCountries(HighlightedCountriesSplit, string.Empty, false, true) 1678 } 1679 1680 @GetHtmlElement("select", true) 1681 1682 @InternalRenderFieldFooter(settings) 1683 } 1684 } 1685 1686 @helper PopulateHighlightedCountries(string label, string value, bool isSelected = false, bool isDisabled = false) 1687 { 1688 HighlightedCountries.Remove(value); 1689 if (value.IsNullOrEmpty()) 1690 { 1691 HighlightedCountries.Remove(label); 1692 } 1693 @SnippetStart("highlightedContries") 1694 @InternalRenderOption(FieldOption.CreateOption(label, value, isSelected, isDisabled)) 1695 @SnippetEnd("highlightedContries") 1696 } 1697 1698 1699 @* Paging helpers *@ 1700 @helper RenderPaging() 1701 { 1702 @RenderPaging( 1703 GetInteger("Ecom:CustomerCenter.Paging.NumPages"), 1704 "CCPage", 1705 GetString("Ecom:CustomerCenter.Paging.Back.URL"), 1706 GetString("Ecom:CustomerCenter.Paging.Forward.URL"), 1707 GetInteger("Ecom:CustomerCenter.Paging.CurrentPage"), 1708 GetLoop("Ecom:CustomerCenter.Paging.Pages"), 1709 "Ecom:CustomerCenter.Paging.PageIndex" 1710 ) 1711 } 1712 1713 @helper RenderPaging(int numOfPages, string pageQueryParameter, int currentPage) 1714 { 1715 var queryParameters = HttpUtility.ParseQueryString(Dynamicweb.Context.Current.Request.Url.Query); 1716 var url = Helpers.GetCurrentUrl(true, true); 1717 var previousPageUrl = string.Empty; 1718 var nextPageUrl = string.Empty; 1719 1720 if (currentPage > 1) 1721 { 1722 queryParameters = Helpers.UpdateQueryStringKeyValue(queryParameters, pageQueryParameter, (currentPage - 1).ToString()); 1723 previousPageUrl = Helpers.BuildUri(url, queryParameters).ToString(); 1724 } 1725 if (currentPage < numOfPages) 1726 { 1727 queryParameters = Helpers.UpdateQueryStringKeyValue(queryParameters, pageQueryParameter, (currentPage + 1).ToString()); 1728 nextPageUrl = Helpers.BuildUri(url, queryParameters).ToString(); 1729 } 1730 1731 @RenderPaging(numOfPages, pageQueryParameter, previousPageUrl, nextPageUrl, currentPage) 1732 } 1733 1734 @helper RenderPaging(int numOfPages, string pageQueryParameter, string previousPageUrl, string nextPageUrl, int currentPage, List<LoopItem> pagesLoop = null, string pageNumTag = "", string pageHrefTag = "", bool includeWrapper = true) 1735 { 1736 if (numOfPages > 1) 1737 { 1738 @* NOTE: pageIndex needs to be a tag name, because it will be instanciated within the loop *@ 1739 @* NOTE: 1740 queryParamenter == "PageNum" --> Product Catalog module 1741 queryParamenter == "page" --> Item Publisher module 1742 queryParamenter == "CC*" --> Customer Center module 1743 queryParamenter == "DWPagingPageNum" --> Data List module 1744 *@ 1745 1746 var loopPageSize = 3; 1747 var startPage = 1; 1748 var endPage = numOfPages; 1749 1750 var pageQueryParameter2 = pageQueryParameter == "PageNum" || pageQueryParameter == "page" || pageQueryParameter == "DWPagingPageNum" ? string.Empty : Pageview.CurrentParagraph.ID.ToString(); 1751 var pageNumQueryParameter = pageQueryParameter + pageQueryParameter2; 1752 1753 var queryParameters = HttpUtility.ParseQueryString(Dynamicweb.Context.Current.Request.Url.Query); 1754 queryParameters.Remove(pageNumQueryParameter); 1755 queryParameters.Remove("pid"); 1756 1757 if (pageQueryParameter == "page") 1758 { 1759 queryParameters.Add("pid", Pageview.CurrentParagraph.ID.ToString()); 1760 } 1761 1762 if (pagesLoop != null) 1763 { 1764 loopPageSize = pagesLoop.Count; 1765 endPage = 1; 1766 } 1767 else 1768 { 1769 var pageOffset = Math.Floor(Convert.ToDecimal(loopPageSize / 2)); 1770 var middlePage = pageOffset + 1; 1771 1772 if (numOfPages > loopPageSize) 1773 { 1774 startPage = Convert.ToInt32(currentPage - pageOffset) < 1 ? 1 : Convert.ToInt32(currentPage - pageOffset); 1775 endPage = Convert.ToInt32(currentPage + pageOffset) > numOfPages ? numOfPages : Convert.ToInt32(currentPage + pageOffset); 1776 1777 if (currentPage < middlePage) 1778 { 1779 endPage = loopPageSize; 1780 } 1781 else if (currentPage >= middlePage) 1782 { 1783 if (numOfPages < currentPage + pageOffset) 1784 { 1785 startPage = numOfPages - loopPageSize; 1786 if (loopPageSize % 2 != 0) 1787 { 1788 startPage += 1; 1789 } 1790 } 1791 1792 if (loopPageSize % 2 == 0) 1793 { 1794 startPage += 1; 1795 } 1796 } 1797 } 1798 } 1799 1800 if (includeWrapper) 1801 { 1802 @:<div class="col-xs-12 text-center paginationContainer"> 1803 } 1804 <ul class="pagination"> 1805 @if (previousPageUrl.IsNotNullOrEmpty() && previousPageUrl != "#") 1806 { 1807 @InternalRenderPageItem(previousPageUrl, Translate("Previous"), "fa-caret-left", IconPosition.Left) 1808 } 1809 @if (pagesLoop != null) 1810 { 1811 @InternalRenderGoToFirstPage(queryParameters, pageNumQueryParameter, currentPage, numOfPages, loopPageSize, pagesLoop[0].GetInteger(pageNumTag)) 1812 foreach (var page in pagesLoop) 1813 { 1814 var pageItemHref = pageQueryParameter == "PageNum" || pageQueryParameter == "page" ? page.GetString(pageHrefTag) : string.Empty; 1815 endPage = page.GetInteger(pageNumTag); 1816 1817 queryParameters.Remove(pageNumQueryParameter); 1818 if (pageItemHref.IsNotNullOrEmpty()) 1819 { 1820 queryParameters.Add(pageNumQueryParameter, page.GetString(pageNumTag)); 1821 } 1822 @InternalRenderPageItem(queryParameters, page.GetString(pageNumTag), page.GetInteger(pageNumTag) == currentPage ? "active" : string.Empty) 1823 1824 } 1825 @InternalRenderGoToLastPage(queryParameters, pageNumQueryParameter, currentPage, numOfPages, loopPageSize, endPage) 1826 } 1827 else 1828 { 1829 @InternalRenderGoToFirstPage(queryParameters, pageNumQueryParameter, currentPage, numOfPages, loopPageSize) 1830 for (var page = startPage; page <= endPage; page++) 1831 { 1832 queryParameters = Helpers.UpdateQueryStringKeyValue(queryParameters, pageNumQueryParameter, page.ToString()); 1833 @InternalRenderPageItem(queryParameters, page.ToString(), page == currentPage ? "active" : string.Empty) 1834 } 1835 @InternalRenderGoToLastPage(queryParameters, pageNumQueryParameter, currentPage, numOfPages, loopPageSize, endPage) 1836 } 1837 1838 @if (nextPageUrl.IsNotNullOrEmpty() && nextPageUrl != "#") 1839 { 1840 @InternalRenderPageItem(nextPageUrl, Translate("Next"), "fa-caret-right", IconPosition.Right) 1841 } 1842 </ul> 1843 if (includeWrapper) 1844 { 1845 @:</div> 1846 } 1847 } 1848 } 1849 1850 1851 @* Generic helpers *@ 1852 @helper RenderIcon(string cssPartialClass, string label = "", IconPosition position = IconPosition.Left, bool isLabelATooltip = false) 1853 { 1854 var icon = !isLabelATooltip ? "<i class='fa " + cssPartialClass + "'></i>" : "<i class='fa " + cssPartialClass + "' data-toggle='" + label + "'></i>"; 1855 var spacing = string.Empty; 1856 1857 if (label.IsNotNullOrEmpty()) 1858 { 1859 spacing = "&nbsp;"; 1860 } 1861 if (cssPartialClass.IsNotNullOrEmpty()) 1862 { 1863 if (isLabelATooltip) 1864 { 1865 @icon 1866 } 1867 else if (position == IconPosition.Left) 1868 { 1869 @icon 1870 @spacing 1871 @label 1872 } 1873 else 1874 { 1875 @label 1876 @spacing 1877 @icon 1878 } 1879 } 1880 else 1881 { 1882 @label 1883 } 1884 } 1885 1886 @helper RenderStackedIcons(string cssPrincipalPartialClass, string cssSecondaryPartialClass, string label = "", IconPosition position = IconPosition.Left, bool isLabelATooltip = false) 1887 { 1888 var spacing = string.Empty; 1889 var icon = new StringBuilder("<span class='fa-stack'>"); 1890 1891 icon.Append(!isLabelATooltip ? "<i class='fa " + cssPrincipalPartialClass + " fa-stack-2x'></i>" : "<i class='fa " + cssPrincipalPartialClass + " fa-stack-2x' data-toggle='" + label + "'></i>"); 1892 icon.Append("<i class='fa " + cssSecondaryPartialClass + " fa-stack-1x'></i>"); 1893 icon.Append("</span>"); 1894 1895 if (label.IsNotNullOrEmpty()) 1896 { 1897 spacing = "<text>&nbsp;</text>"; 1898 } 1899 if (cssPrincipalPartialClass.IsNotNullOrEmpty() && cssSecondaryPartialClass.IsNotNullOrEmpty()) 1900 { 1901 if (isLabelATooltip) 1902 { 1903 @icon.ToString() 1904 } 1905 else if (position == IconPosition.Left) 1906 { 1907 @icon.ToString() 1908 @spacing 1909 @label 1910 } 1911 else 1912 { 1913 @label 1914 @spacing 1915 @icon.ToString() 1916 } 1917 } 1918 else 1919 { 1920 @label 1921 } 1922 } 1923 1924 @helper RenderAction(IconAction action, string href = "", string title = "", string onClickConfirm = "") 1925 { 1926 var attributes = new Dictionary<string, string>(); 1927 1928 if (title.IsNotNullOrEmpty()) 1929 { 1930 attributes.Add("title", title); 1931 } 1932 if (onClickConfirm.IsNotNullOrEmpty()) 1933 { 1934 attributes.Add("onclick", "return confirm('" + onClickConfirm + "');"); 1935 } 1936 if (href.IsNotNullOrEmpty()) 1937 { 1938 attributes.Add("href", href); 1939 } 1940 @RenderAction(action, href, attributes) 1941 } 1942 1943 @helper RenderAction(IconAction action, string href, Dictionary<string, string> attributes) 1944 { 1945 var icon = string.Empty; 1946 var linkAttributes = string.Empty; 1947 var label = Translate(action.ToString()); 1948 1949 switch (action) 1950 { 1951 case IconAction.Add: 1952 break; 1953 case IconAction.View: 1954 icon = "fa-eye"; 1955 break; 1956 case IconAction.Edit: 1957 icon = "fa-edit"; 1958 break; 1959 case IconAction.Cancel: 1960 case IconAction.Remove: 1961 icon = "fa-times"; 1962 break; 1963 case IconAction.Delete: 1964 icon = "fa-trash"; 1965 break; 1966 case IconAction.Print: 1967 icon = "fa-print"; 1968 attributes.Add("target", "_blank"); 1969 label = string.Empty; 1970 break; 1971 case IconAction.Save: 1972 break; 1973 case IconAction.Reset: 1974 break; 1975 case IconAction.Undo: 1976 break; 1977 case IconAction.Reorder: 1978 icon = "fa-repeat"; 1979 break; 1980 case IconAction.SetDefault: 1981 icon = "fa-times"; 1982 label = string.Empty; 1983 break; 1984 case IconAction.IsDefault: 1985 icon = "fa-check"; 1986 label = string.Empty; 1987 break; 1988 default: 1989 throw new NotSupportedException("An action is needed to render this helper!"); 1990 } 1991 if (icon.IsNotNullOrEmpty()) 1992 { 1993 if (href.IsNotNullOrEmpty()) 1994 { 1995 @GetHtmlElement("a", GetAttributes(attributes)) 1996 @RenderIcon(icon, label) 1997 @GetHtmlElement("a", true) 1998 } 1999 else if (label.IsNullOrEmpty()) 2000 { 2001 @RenderIcon(icon) 2002 } 2003 } 2004 2005 } 2006 2007 @helper RenderBootstrapButton(BootstrapButtonSettings settings) 2008 { 2009 var attributes = new StringBuilder(GetAttribute("class", "btn " + (settings.CssClass.IsNotNullOrEmpty() ? settings.CssClass : "btn-default"))); 2010 attributes.Append(GetAttribute("target", settings.Target)); 2011 attributes.Append(GetAttribute("href", settings.Href)); 2012 attributes.Append(GetAttribute("name", settings.SystemName)); 2013 attributes.Append(GetAttribute("id", settings.Id)); 2014 attributes.Append(GetAttribute("value", settings.Value)); 2015 if (settings.ButtonType == BootstrapButtonSettings.BootstrapButtonType.Button && !settings.Attributes.ContainsKey("type")) 2016 { 2017 settings.Attributes.Add("type","submit"); 2018 } 2019 2020 attributes.Append(GetAttributes(settings.Attributes)); 2021 string htmlElement; 2022 2023 switch (settings.ButtonType) 2024 { 2025 case BootstrapButtonSettings.BootstrapButtonType.Button: 2026 htmlElement = "button"; 2027 break; 2028 case BootstrapButtonSettings.BootstrapButtonType.Anchor: 2029 htmlElement = "a"; 2030 break; 2031 default: 2032 throw new NotSupportedException(string.Format("Unsupported Bootstrap Button type: {0}.", settings.ButtonType.ToString())); 2033 } 2034 @GetHtmlElement(htmlElement, attributes.ToString()) 2035 @RenderIcon(settings.IconCssClass, settings.Label, settings.IconPosition) 2036 @GetHtmlElement(htmlElement, true) 2037 } 2038 2039 @helper RenderAddToCart(string productId, string productVariantId, int availableAmount = 0, bool doNotRenderHiddenFields = false) 2040 { 2041 var addToCartButtonSettings = new BootstrapButtonSettings 2042 { 2043 Label = Translate("Add to Cart"), 2044 CssClass = availableAmount <= 0 ? "btn-default addToCartSubmit disabled" : "btn-default addToCartSubmit", 2045 Href = string.Concat(Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MiniCart").ID),"?productid=", productId, "&amp;variantID=", productVariantId, "&amp;cartcmd=add"), 2046 IconCssClass = "fa-shopping-cart", 2047 Attributes = new Dictionary<string, string> 2048 { 2049 {"data-add", Translate("Add to Cart")}, 2050 {"data-added", Translate("Added")}, 2051 {"data-outofstock", Translate("Out of stock")}, 2052 {"data-stock", availableAmount.ToString()} 2053 } 2054 }; 2055 @RenderBootstrapButton(addToCartButtonSettings) 2056 if (!doNotRenderHiddenFields) 2057 { 2058 @RenderField(FieldSettings.CreateHiddenField("redirect", "false", "redirect" + productId)) 2059 @RenderField(FieldSettings.CreateHiddenField("cartcmd", "add", "cartcmd" + productId)) 2060 @RenderField(FieldSettings.CreateHiddenField("productid", productId, "productId" + productId)) 2061 @RenderField(FieldSettings.CreateHiddenField("variantid", productVariantId, "variantId" + productId + productVariantId)) 2062 } 2063 @RenderField(FieldSettings.CreateSubmitField(Translate("Add to Cart"), "hidden")) 2064 } 2065 2066 @helper RenderSocialMediaShare() 2067 { 2068 <div class="shareIcons"> 2069 <span>@Translate("Share")</span> 2070 @RenderSocialMedia(false, true) 2071 </div> 2072 } 2073 2074 @helper RenderOpenGraphMeta(string type, string image, string title, string teaser = "", string imageAlt = "") 2075 { 2076 var culture = Pageview.Area.Culture.Replace("-", "_"); 2077 teaser = System.Text.RegularExpressions.Regex.Replace(teaser, "<.*?>", string.Empty); 2078 if (type.IsNullOrEmpty()) 2079 { 2080 type = "article"; 2081 } 2082 if (imageAlt.IsNullOrEmpty()) 2083 { 2084 imageAlt = title; 2085 } 2086 2087 @SnippetStart("OGMeta") 2088 <meta property="og:title" content="@HttpUtility.HtmlEncode(title)"/> 2089 <meta property="og:image" content="@string.Concat(Helpers.GetCurrentUrl(true), image)"/> 2090 <meta property="og:image:width" content="600"/> 2091 <meta property="og:image:height" content="600"/> 2092 <meta property="og:image:alt" content="@HttpUtility.HtmlEncode(imageAlt)"/> 2093 <meta property="og:site_name" content="@Pageview.Area.Item["CompanyName"]"/> 2094 <meta property="og:url" content="@Helpers.GetCurrentUrl()"/> 2095 <meta property="og:description" content="@HttpUtility.HtmlEncode(teaser)"/> 2096 <meta property="og:type" content="@type"/> 2097 <meta property="og:locale" content="@culture"/> 2098 @SnippetEnd("OGMeta") 2099 } 2100 2101 @helper RenderSocialMedia(bool isEmailTemplate = false, bool isToShare = false) 2102 { 2103 var page = Dynamicweb.Extensibility.ServiceLocator.Current.GetPageService().GetPage(Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "GeneralSettings").ID); 2104 var generalSettings = Dynamicweb.Content.Items.Item.GetItemById(page.ItemType, page.ItemId); 2105 2106 if(generalSettings["SocialMedia"] != null) { 2107 var socialMedia = Dynamicweb.Content.Items.ItemList.GetItemListById(int.Parse(generalSettings["SocialMedia"].ToString())); 2108 2109 if(socialMedia.Relations.Any()) 2110 { 2111 if(!isEmailTemplate) 2112 { 2113 @:<ul class="socialMedia"> 2114 } 2115 foreach (var r in socialMedia.Relations) 2116 { 2117 var socialNetwork = Dynamicweb.Content.Items.Item.GetItemById("SocialLinks", r.Id); 2118 var className = (socialNetwork["Icon"] ?? "").ToString(); 2119 var socialName = (socialNetwork["Name"] ?? "").ToString(); 2120 var socialLink = (socialNetwork["Link"] ?? "").ToString(); 2121 var shareLink = (socialNetwork["ShareURL"] ?? "").ToString(); 2122 2123 if (isEmailTemplate) 2124 { 2125 @:&nbsp; 2126 <a title="@socialName" target="_blank" href="@socialLink">@socialName</a> 2127 @:&nbsp; 2128 } 2129 else if(!isToShare || shareLink.IsNotNullOrEmpty()) 2130 { 2131 <li> 2132 <a title="@socialName" class="@className fa" target="_blank" data-sharehref="@shareLink@Helpers.GetCurrentUrl()" href="@socialLink"><span class="hidden">@socialName</span></a> 2133 </li> 2134 } 2135 } 2136 if(!isEmailTemplate) 2137 { 2138 @:</ul> 2139 } 2140 } 2141 } 2142 } 2143 2144 @helper RenderNoResults(string wording, string title = "", bool hasWrapper = false, string wrapperClass = "col-xs-12 noPadding" ) 2145 { 2146 if (hasWrapper) 2147 { 2148 @:<div class="noResultsWrapper @wrapperClass"> 2149 } 2150 if (title.IsNotNullOrEmpty()) 2151 { 2152 <h2>@title</h2> 2153 } 2154 <p>@wording</p> 2155 if (hasWrapper) 2156 { 2157 @:</div> 2158 } 2159 } 2160 2161 @helper RenderImage(ImageSettings imageSettings) 2162 { 2163 var imageMarkup = new StringBuilder(); 2164 var widthAndHeight = GetWidthAndHeightFromQueryString(imageSettings.Source); 2165 var widthAndHeightForMobile = GetWidthAndHeightFromQueryString(imageSettings.SourceForMobile, true); 2166 var widthAndHeightForTablet = GetWidthAndHeightFromQueryString(imageSettings.SourceForTablet, true); 2167 2168 if (!imageSettings.Attributes.ContainsKey("width") && widthAndHeight.ContainsKey("width") && widthAndHeight["width"].IsNotNullOrEmpty()) 2169 { 2170 imageSettings.Attributes.Add("width", widthAndHeight["width"]); 2171 } 2172 if (!imageSettings.Attributes.ContainsKey("height") && widthAndHeight.ContainsKey("height") && widthAndHeight["height"].IsNotNullOrEmpty()) 2173 { 2174 imageSettings.Attributes.Add("height", widthAndHeight["height"]); 2175 } 2176 if (!imageSettings.Attributes.ContainsKey("class")) 2177 { 2178 imageSettings.Attributes.Add("class", "img-responsive " + imageSettings.CssClass); 2179 } 2180 if (!imageSettings.Attributes.ContainsKey("src")) 2181 { 2182 imageSettings.Attributes.Add("src", imageSettings.Source); 2183 } 2184 if (!imageSettings.Attributes.ContainsKey("alt")) 2185 { 2186 imageSettings.Attributes.Add("alt", imageSettings.AltText); 2187 } 2188 if (!imageSettings.Attributes.ContainsKey("title")) 2189 { 2190 imageSettings.Attributes.Add("title", imageSettings.Title); 2191 } 2192 2193 if (imageSettings.IncludeWrapper) 2194 { 2195 var wrapperAttributes = new Dictionary<string, string>(); 2196 if (imageSettings.WrapperCssClass.IsNotNullOrEmpty()) 2197 { 2198 wrapperAttributes.Add("class", imageSettings.WrapperCssClass); 2199 } 2200 2201 imageMarkup.Append(GetHtmlElement(imageSettings.WrapperElement, wrapperAttributes)); 2202 } 2203 2204 if (imageSettings.Href.IsNotNullOrEmpty()) 2205 { 2206 var linkAttributes = new Dictionary<string, string> {{"href", imageSettings.Href}}; 2207 if (imageSettings.HrefCssClass.IsNotNullOrEmpty()) 2208 { 2209 linkAttributes.Add("class", imageSettings.HrefCssClass); 2210 } 2211 if (imageSettings.HrefTarget.IsNotNullOrEmpty()) 2212 { 2213 linkAttributes.Add("target", imageSettings.HrefTarget); 2214 } 2215 2216 imageMarkup.Append(GetHtmlElement("a", linkAttributes)); 2217 } 2218 2219 if (widthAndHeightForMobile.Any() || widthAndHeightForTablet.Any()) 2220 { 2221 imageMarkup.Append(GetHtmlElement("picture")); 2222 2223 imageMarkup.Append(GetHtmlElement("source")); 2224 2225 if (widthAndHeightForMobile.Any()) 2226 { 2227 imageMarkup.Append(GetHtmlElement("srcset", widthAndHeightForMobile)); 2228 } 2229 2230 if (widthAndHeightForTablet.Any()) 2231 { 2232 imageMarkup.Append(GetHtmlElement("srcset", widthAndHeightForTablet)); 2233 } 2234 2235 imageMarkup.Append(GetHtmlElement("source", true)); 2236 } 2237 2238 imageMarkup.Append(GetHtmlElement("img", imageSettings.Attributes, true)); 2239 2240 if (imageSettings.SourceForMobile.IsNotNullOrEmpty() || imageSettings.SourceForTablet.IsNotNullOrEmpty()) 2241 { 2242 imageMarkup.Append(GetHtmlElement("picture", true)); 2243 } 2244 2245 if (imageSettings.Href.IsNotNullOrEmpty()) 2246 { 2247 imageMarkup.Append(GetHtmlElement("a", true)); 2248 } 2249 2250 if (imageSettings.IncludeWrapper) 2251 { 2252 imageMarkup.Append(GetHtmlElement(imageSettings.WrapperElement, true)); 2253 } 2254 2255 @imageMarkup.ToString() 2256 } 2257 2258 @helper RenderHtmlElementBetweenEachString(List<string> listOfStrings, string htmlElement = "br" ) 2259 { 2260 foreach (var str in listOfStrings) 2261 { 2262 if (str.IsNullOrEmpty()){continue;} 2263 @(string.Concat(str, GetHtmlElement(htmlElement, true))) 2264 } 2265 } 2266 2267 @helper RenderProductPrice(string productPrice = "") 2268 { 2269 var showNoErpConnectionMessage = ShowNoErpConnectionMessage(); 2270 var isWebServiceConnectionAvailable = Dna.Ecommerce.LiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 2271 2272 if (!isWebServiceConnectionAvailable && showNoErpConnectionMessage) 2273 { 2274 if (productPrice.IsNullOrEmpty()) 2275 { 2276 @RenderNoErpConnectionMessage() 2277 } 2278 else 2279 { 2280 <span class="noErpConnection">@Translate("Unavailable")</span> 2281 } 2282 } 2283 else 2284 { 2285 @productPrice 2286 } 2287 } 2288 2289 @helper RenderNoErpConnectionMessage() 2290 { 2291 <div class="col-xs-12 warningBox"> 2292 <p>@Translate("Pricing and inventory are currently not available. Please check back soon")</p> 2293 </div> 2294 } 2295 } 2296 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 2297 @using Dynamicweb.Rendering 2298 @using System 2299 @using System.Collections.Generic 2300 @using System.Globalization 2301 @using System.Linq 2302 @using System.Web 2303 @using System.Web.Script.Serialization 2304 @using Dna.Frontend 2305 @using Dna.Frontend.Forms 2306 @using Dna.Frontend.UI 2307 @using Dna.UrlServices 2308 @using Dynamicweb.Core 2309 @using Dynamicweb.Ecommerce.Orders 2310 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 2311 @using Dynamicweb.Forms 2312 @using Dynamicweb.Security.UserManagement 2313 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 2314 @using Dynamicweb.Rendering 2315 @using System 2316 @using System.Linq 2317 @using System.Web 2318 @using Dna.Frontend 2319 @using Dna.Validation 2320 @using Dna.Frontend.UI 2321 @using Dna.UrlServices 2322 @using Dynamicweb.Core 2323 @using Dynamicweb.Ecommerce.Orders 2324 @using Dynamicweb.Frontend 2325 @using Dynamicweb.Security.UserManagement 2326 @functions 2327 { 2328 2329 public void CreateNewAddress(AddressSource addressSource) 2330 { 2331 switch (addressSource) 2332 { 2333 case AddressSource.EcomCustomer: 2334 CreateNewAddress( 2335 GetString("Ecom:Order.Customer.Address"), 2336 GetString("Ecom:Order.Customer.Address2"), 2337 GetString("Ecom:Order.Customer.City"), 2338 GetString("Ecom:Order.Customer.Region"), 2339 GetString("Ecom:Order.Customer.Zip"), 2340 GetString("Ecom:Order.Customer.Country.Code"), 2341 Pageview.User.ID 2342 ); 2343 break; 2344 case AddressSource.EcomDelivery: 2345 CreateNewAddress( 2346 GetString("Ecom:Order.Delivery.Address"), 2347 GetString("Ecom:Order.Delivery.Address2"), 2348 GetString("Ecom:Order.Delivery.City"), 2349 GetString("Ecom:Order.Delivery.Region"), 2350 GetString("Ecom:Order.Delivery.Zip"), 2351 GetString("Ecom:Order.Delivery.Country.Code"), 2352 Pageview.User.ID 2353 ); 2354 break; 2355 case AddressSource.UserProfile: 2356 case AddressSource.UserAddress: 2357 throw new NotImplementedException(string.Format("The Rizzo address source {0} has not been developed", addressSource)); 2358 default: 2359 throw new ArgumentOutOfRangeException("addressSource property", addressSource, null); 2360 } 2361 2362 } 2363 2364 public void CreateNewAddress(string address, string address2, string city, string state, string zip, string country, int userId ) 2365 { 2366 var newAddress = new UserAddress 2367 { 2368 Address = address, 2369 Address2 = address2, 2370 City = city, 2371 State = state, 2372 Zip = zip, 2373 CountryCode = country, 2374 UserID = userId 2375 }; 2376 newAddress.Save(); 2377 } 2378 2379 public void UpdateUserAddress(AddressSource addressSource, int addressId, string addressName = "") 2380 { 2381 switch (addressSource) 2382 { 2383 case AddressSource.EcomCustomer: 2384 UpdateUserAddress( 2385 GetString("Ecom:Order.Customer.Address"), 2386 GetString("Ecom:Order.Customer.Address2"), 2387 GetString("Ecom:Order.Customer.City"), 2388 GetString("Ecom:Order.Customer.Region"), 2389 GetString("Ecom:Order.Customer.Zip"), 2390 GetString("Ecom:Order.Customer.Country.Code"), 2391 addressId, 2392 addressName 2393 ); 2394 break; 2395 case AddressSource.EcomDelivery: 2396 UpdateUserAddress( 2397 GetString("Ecom:Order.Delivery.Address"), 2398 GetString("Ecom:Order.Delivery.Address2"), 2399 GetString("Ecom:Order.Delivery.City"), 2400 GetString("Ecom:Order.Delivery.Region"), 2401 GetString("Ecom:Order.Delivery.Zip"), 2402 GetString("Ecom:Order.Delivery.Country.Code"), 2403 addressId, 2404 addressName 2405 ); 2406 break; 2407 case AddressSource.UserProfile: 2408 case AddressSource.UserAddress: 2409 throw new NotImplementedException(string.Format("The Rizzo address source {0} has not been developed", addressSource)); 2410 default: 2411 throw new ArgumentOutOfRangeException("addressSource property", addressSource, null); 2412 } 2413 } 2414 2415 public void UpdateUserAddress(string address, string address2, string city, string state, string zip, string country, int addressId, string addressName ) 2416 { 2417 if (addressId == Pageview.User.ID) 2418 { 2419 var addressToUpdate = User.GetCurrentUser(PagePermissionLevels.Frontend); 2420 2421 addressToUpdate.Address = address; 2422 addressToUpdate.Address2 = address2; 2423 addressToUpdate.City = city; 2424 addressToUpdate.State = state; 2425 addressToUpdate.Zip = zip; 2426 addressToUpdate.CountryCode = country; 2427 addressToUpdate.Save(); 2428 } 2429 else 2430 { 2431 var addressToUpdate = UserAddress.GetUserAddressById(addressId); 2432 addressToUpdate.Name = addressName; 2433 addressToUpdate.Address = address; 2434 addressToUpdate.Address2 = address2; 2435 addressToUpdate.City = city; 2436 addressToUpdate.State = state; 2437 addressToUpdate.Zip = zip; 2438 addressToUpdate.CountryCode = country; 2439 addressToUpdate.Save(); 2440 } 2441 } 2442 2443 public void CreateAddressFromBillingAndShipping() 2444 { 2445 if (HttpContext.Current.Request.Cookies["SaveAddress"] == null) return; 2446 2447 var saveAddressCookie = HttpContext.Current.Request.Cookies["SaveAddress"]; 2448 2449 if (saveAddressCookie.HasKeys) 2450 { 2451 if(saveAddressCookie["SaveBillingAddress"] != null) { 2452 if (saveAddressCookie["SaveBillingAddress"] == "True") 2453 { 2454 if (!IsAnUserAddress(GetAddressHash(AddressSource.EcomCustomer))) 2455 { 2456 CreateNewAddress(AddressSource.EcomCustomer); 2457 } 2458 } 2459 if (saveAddressCookie["SaveDeliveryAddress"] == "True") 2460 { 2461 if (!IsAnUserAddress(GetAddressHash(AddressSource.EcomDelivery))) 2462 { 2463 CreateNewAddress(AddressSource.EcomDelivery); 2464 } 2465 } 2466 } 2467 else 2468 { 2469 if (saveAddressCookie["UpdateBillingAddress"] != null) 2470 { 2471 int num; 2472 if(int.TryParse(saveAddressCookie["UpdateBillingAddress"], out num)) 2473 { 2474 UpdateUserAddress(AddressSource.EcomCustomer, num); 2475 } 2476 } 2477 if (saveAddressCookie["UpdateDeliveryAddress"] != null) 2478 { 2479 int num; 2480 var addressName = saveAddressCookie["DeliveryAddressName"] ?? string.Empty; 2481 if (int.TryParse(saveAddressCookie["UpdateDeliveryAddress"], out num)) 2482 { 2483 UpdateUserAddress(AddressSource.EcomDelivery, num, addressName); 2484 } 2485 } 2486 } 2487 } 2488 saveAddressCookie.Expires = DateTime.Now.AddDays(-1d); 2489 HttpContext.Current.Response.Cookies.Add(saveAddressCookie); 2490 } 2491 2492 public bool IsAnUserAddress(string addressHash) 2493 { 2494 return UserAddress.GetUserAddresses(Pageview.User.ID).Any(address => string.Equals(GetAddressHash(address.Address, address.Address2, address.City, address.State, address.Zip, address.Country), addressHash, StringComparison.OrdinalIgnoreCase)); 2495 } 2496 2497 } 2498 @{ 2499 2500 @helper InternalRenderCartContentLine(LoopItem orderline, CartOutputType outputType = CartOutputType.ReadOnly, bool isOutOfStock = false) 2501 { 2502 @* 2503 Simulate request of tags to trigger DW's template engine render the property data 2504 @GetString("Ecom:Product.ImageSmall.Clean") 2505 @GetString("Ecom:Product.ImageMedium.Clean") 2506 @GetString("Ecom:Product.ImageLarge.Clean") 2507 @GetString("Ecom:Product:Field.ImageFileNamingPart.Value.Clean") 2508 *@ 2509 var isService = orderline.GetInteger("Ecom:Product.Type") == 1; 2510 var productStock = isService ? 10000 : orderline.GetInteger("Ecom:Product.Stock"); 2511 var productAvailableAmount = isService ? 10000 : orderline.GetInteger("Ecom:Product.AvailableAmount"); 2512 var productQuantity = orderline.GetInteger("Ecom:Order:OrderLine.Quantity"); 2513 var productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 2514 var productName = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 2515 var productNumber = orderline.GetString("Ecom:Product.Number"); 2516 var productImage = orderline.GetImagePath(); 2517 var imageUrl = Images.GetImage(productImage, 95, 95); 2518 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 2519 var productUrl = SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=" + Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "Products").ID + "&GroupID=" + orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID") + "&ProductID=" +productId); 2520 var figureClass = outputType == CartOutputType.MiniCart ? "text-center col-xs-3 col-sm-3 noPadding" : "text-center col-xs-4 col-sm-4"; 2521 var prodContainerClass = outputType == CartOutputType.MiniCart ? "col-xs-9 col-sm-9 noPaddingRight" : "col-xs-8 col-sm-8 prodName noPadding"; 2522 var productFriendlyUrl = string.Concat(Helpers.GetCurrentUrl(true), productUrl); 2523 var shareFacebookUrl = string.Concat("https://www.facebook.com/sharer/sharer.php?u=",productFriendlyUrl); 2524 var shareTwitterUrl = string.Concat("https://twitter.com/home?status=", productFriendlyUrl); 2525 var imageSettings = new ImageSettings 2526 { 2527 Source = imageUrl, 2528 AltText = productName, 2529 Href = productUrl, 2530 IncludeWrapper = true, 2531 WrapperElement = Sanitize.Parameter("print").IsNotNullOrEmpty() ? "div" : "figure", 2532 WrapperCssClass = figureClass 2533 }; 2534 2535 <li class="col-xs-12 noPadding" data-facebook="@shareFacebookUrl" data-twitter="@shareTwitterUrl"> 2536 @if (outputType != CartOutputType.MiniCart) 2537 { 2538 @:<div class="col-xs-12 col-sm-4 noPaddingLeft noPadding-xs"> 2539 } 2540 2541 @RenderImage(imageSettings) 2542 2543 <div class="@prodContainerClass"> 2544 <h2> 2545 <a href="@productUrl"> 2546 <strong>@productName</strong> 2547 @if (variantText.IsNotNullOrEmpty()) 2548 { 2549 <br/> 2550 <small>@variantText</small> 2551 } 2552 </a> 2553 </h2> 2554 @if (outputType == CartOutputType.MiniCart) 2555 { 2556 <span class="col-xs-12 noPadding"> 2557 <strong>@Translate("Qty"): </strong>@orderline.GetString("Ecom:Order:OrderLine.Quantity") <span class="pull-right">@RenderProductPrice(orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVATFormatted"))</span> 2558 </span> 2559 } 2560 else if (productNumber.IsNotNullOrEmpty() && outputType != CartOutputType.MiniCart) 2561 { 2562 <div class="itemDetails"> 2563 @Translate("Item number"): @productNumber 2564 </div> 2565 } 2566 </div> 2567 2568 @if (outputType != CartOutputType.MiniCart) 2569 { 2570 @:</div> 2571 } 2572 2573 2574 @if (outputType != CartOutputType.MiniCart) 2575 { 2576 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight"> 2577 @{ 2578 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 2579 if (orderLineType == OrderLineType.PointProduct) 2580 { 2581 @:@orderline.GetString("Ecom:Order:OrderLine.UnitPoints")&nbsp;@Translate(orderline.GetString("Ecom:Order:OrderLine.UnitPoints") == "1" ? "point" : "points") 2582 } 2583 else 2584 { 2585 @orderline.GetString("Ecom:Order:OrderLine.UnitPrice") 2586 } 2587 } 2588 </div> 2589 2590 if (isOutOfStock) 2591 { 2592 var stockAvailable = productStock <= 0 ? 0 : productStock; 2593 <div class="col-xs-4 col-xs-offset-4 col-sm-offset-0 col-sm-2 noPadding stockAvailable mdAlignRight">@stockAvailable</div> 2594 <div class="col-xs-4 col-xs-offset-4 col-sm-offset-0 col-sm-2 noPadding productQuantity mdAlignRight">@productQuantity</div> 2595 } 2596 else 2597 { 2598 <div class="col-xs-4 col-xs-offset-4 col-sm-offset-0 col-sm-2 quantity noPaddingLeft mdAlignRight"> 2599 <strong class="hidden-sm hidden-md hidden-lg pull-left">@Translate("Qty")&nbsp;&nbsp;</strong> 2600 @if (outputType != CartOutputType.Editable || orderLineType == OrderLineType.Discount || orderLineType == OrderLineType.ProductDiscount || orderLineType == OrderLineType.GiftCard || orderline.GetInteger("Ecom:Product.Type") == 1) 2601 { 2602 @productQuantity 2603 } 2604 else 2605 { 2606 <form class="cartChange" method="POST" action="@SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> 2607 @InternalRenderQuantityField(productStock, productAvailableAmount, productQuantity, orderline.GetString("Ecom:Order:OrderLine.Quantity.Input.Name"), 10, true, variantText.IsNotNullOrEmpty()) 2608 </form> 2609 } 2610 </div> 2611 2612 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 discount noPadding mdAlignRight"> 2613 <span class="hidden-sm hidden-md hidden-lg">@Translate("Discount"):</span> 2614 @if ((orderline.GetDouble("Ecom:Order:OrderLine.Price.PriceWithoutVAT.Value") - orderline.GetDouble("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVAT.Value")) > 0) 2615 { 2616 @orderline.GetString("Ecom:Order:OrderLine.Price.Currency.Symbol")@(orderline.GetDouble("Ecom:Order:OrderLine.Price.PriceWithoutVAT.Value") - orderline.GetDouble("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVAT.Value")) 2617 } 2618 else 2619 { 2620 @:-.-- 2621 } 2622 2623 2624 </div> 2625 } 2626 2627 <div class="col-xs-12 col-sm-2 totalPrice noPadding text-right noPadding-xs mdAlignRight"> 2628 @orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVATFormatted") 2629 @if (outputType == CartOutputType.Editable && !orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount")) 2630 { 2631 <a class="removeFromCart" href="@orderline.GetString("Ecom:Order:OrderLine.DeleteLink")"> 2632 @RenderIcon("fa-times") 2633 </a> 2634 } 2635 </div> 2636 } 2637 </li> 2638 } 2639 2640 @helper InternalRenderEmailCartContentLine(LoopItem orderline) 2641 { 2642 var domain = Helpers.GetCurrentUrl(true) + "/"; 2643 var productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 2644 var productName = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 2645 var productNumber = orderline.GetString("Ecom:Product.Number"); 2646 var productImage = orderline.GetImagePath(); 2647 var imageUrl = domain + Images.GetImage(productImage, 95, 123); 2648 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 2649 var productUrl = "Default.aspx?Id=" + Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "Products").ID + "&amp;GroupID=" + orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID") + "&amp;ProductID=" + productId; 2650 productUrl = domain + SearchEngineFriendlyURLs.GetFriendlyUrl(productUrl); 2651 2652 @RenderTableRowSpacer(10, 3) 2653 <tr> 2654 <td> 2655 <figure align="left"> 2656 <a target="_blank" href="@productUrl"> 2657 <img alt="@productName" title="@productName" src="@imageUrl" width="95" /> 2658 </a> 2659 </figure> 2660 </td> 2661 <td valign="top"> 2662 <a target="_blank" href="@productUrl"> 2663 <strong>@productName</strong> 2664 @if (variantText.IsNotNullOrEmpty() || productNumber.IsNotNullOrEmpty()) 2665 { 2666 <br/> 2667 } 2668 @if (variantText.IsNotNullOrEmpty()) 2669 { 2670 @variantText 2671 if (productNumber.IsNotNullOrEmpty()) 2672 { 2673 <text> - </text> 2674 } 2675 } 2676 @if (productNumber.IsNotNullOrEmpty()) 2677 { 2678 <text>@Translate("Item number"): @productNumber</text> 2679 } 2680 </a> 2681 <br/> 2682 @{ 2683 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 2684 if (orderLineType == OrderLineType.PointProduct) 2685 { 2686 @:<strong>@orderline.GetString("Ecom:Order:OrderLine.UnitPoints")&nbsp;@Translate(orderline.GetString("Ecom:Order:OrderLine.UnitPoints") == "1" ? "point" : "points")</strong> 2687 } 2688 else 2689 { 2690 <strong>@Translate("Unit price")</strong> 2691 @orderline.GetString("Ecom:Order:OrderLine.UnitPrice") 2692 } 2693 } 2694 <br/> 2695 <strong>@Translate("Quantity")</strong> @orderline.GetString("Ecom:Order:OrderLine.Quantity") 2696 <br/> 2697 </td> 2698 <td class="noPadding" valign="top" style="text-align: right; padding-right: 90px"> 2699 <strong>@orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVATFormatted")</strong> 2700 </td> 2701 </tr> 2702 <tr> 2703 <td style="border-bottom: 1px solid @GetPalletColorNumber(1) text-align:left" colspan="3" height="10"></td> 2704 </tr> 2705 } 2706 2707 @helper InternalRenderTotalAmountLine(string label, string value, bool isBold = false, CartOutputType outputType = CartOutputType.ReadOnly) 2708 { 2709 if (outputType == CartOutputType.Email) 2710 { 2711 <tr align="left"> 2712 <td> 2713 @InternalRenderValue(label, isBold) 2714 </td> 2715 <td> 2716 &nbsp; 2717 </td> 2718 <td class="noPadding" style="padding-right: 90px; text-align: right;"> 2719 @InternalRenderValue(value, isBold) 2720 </td> 2721 </tr> 2722 } 2723 else 2724 { 2725 <div class="col-xs-6 col-sm-7 noPadding clearLeft"> 2726 @InternalRenderValue(label, isBold) 2727 </div> 2728 <div class="col-xs-6 col-sm-5 price pull-right noPadding-xs text-right"> 2729 @InternalRenderValue(value, isBold) 2730 </div> 2731 } 2732 } 2733 2734 @helper InternalRenderValue(string value, bool isBold = false) 2735 { 2736 if (isBold) 2737 { 2738 <strong>@value</strong> 2739 } 2740 else 2741 { 2742 @value 2743 } 2744 } 2745 2746 @helper InternalRenderCartSummaryLine(string label, string value, string labelId = "", string valueId = "", bool isBold = false, bool hasValidation = false) 2747 { 2748 var classToHide = hasValidation && (label.IsNullOrEmpty() || value.IsNullOrEmpty()) ? "hidden" : ""; 2749 2750 <dt id="@labelId" class="col-xs-8 @classToHide"> 2751 @if (isBold) 2752 { 2753 @: <strong> 2754 } 2755 @label 2756 @if (isBold) 2757 { 2758 @: </strong> 2759 } 2760 </dt> 2761 <dd id="@valueId" class="col-xs-4 text-right @classToHide"> 2762 @if (isBold) 2763 { 2764 @: <strong> 2765 } 2766 @value 2767 @if (isBold) 2768 { 2769 @: </strong> 2770 } 2771 </dd> 2772 } 2773 2774 @helper InternalRenderOrderAmountsDisclaimer() 2775 { 2776 @* Taxes and Shipping disclaimer *@ 2777 if (GetString("Ecom:Order.Taxes.Total.Price") == "0.00" || GetBoolean("Ecom:Order.ShippingFee.IsZero")) 2778 { 2779 <small class="col-xs-12 noPadding"> 2780 @if (GetBoolean("Ecom:Order.ShippingFee.IsZero") && GetString("Ecom:Order.Taxes.Total.Price") == "0.00") 2781 { 2782 @Translate("* Taxes and Shipping calculated at Checkout") 2783 } 2784 else 2785 { 2786 @Translate("*Taxes Calculated at Checkout") 2787 } 2788 </small> 2789 } 2790 } 2791 } 2792 @functions 2793 { 2794 2795 public bool AreAddressesTheSame() 2796 { 2797 var customerAddressHash = GetAddressHash(AddressSource.EcomCustomer); 2798 var deliveryAddressHash = GetAddressHash(AddressSource.EcomDelivery); 2799 2800 return customerAddressHash == deliveryAddressHash; 2801 } 2802 2803 public string GetAddressHash(int addressId) 2804 { 2805 var address = UserAddress.GetUserAddressById(addressId); 2806 return GetAddressHash(address.Address, address.Address2, address.City, address.Region.TwoLetterISORegionName, address.Zip, address.Country); 2807 } 2808 2809 public string GetAddressHash(AddressSource addressSource) 2810 { 2811 switch (addressSource) 2812 { 2813 case AddressSource.EcomCustomer: 2814 return GetAddressHash(GetString("Ecom:Order.Customer.Address"), GetString("Ecom:Order.Customer.Address2"), GetString("Ecom:Order.Customer.City"), GetString("Ecom:Order.Customer.Region"), GetString("Ecom:Order.Customer.Zip"), GetString("Ecom:Order.Customer.Country")); 2815 case AddressSource.EcomDelivery: 2816 return GetAddressHash(GetString("Ecom:Order.Delivery.Address"), GetString("Ecom:Order.Delivery.Address2"), GetString("Ecom:Order.Delivery.City"), GetString("Ecom:Order.Delivery.Region"), GetString("Ecom:Order.Delivery.Zip"), GetString("Ecom:Order.Delivery.Country")); 2817 case AddressSource.UserProfile: 2818 return GetAddressHash(GetString("UserManagement:User.Address"), GetString("UserManagement:User.Address2"), GetString("UserManagement:User.City"), GetString("UserManagement:User.State"), GetString("UserManagement:User.Zip"), GetString("UserManagement:User.Country")); 2819 case AddressSource.UserAddress: 2820 throw new NotSupportedException("Unsupported address source. Use an AddressId instead"); 2821 default: 2822 throw new ArgumentOutOfRangeException("addressSource property", addressSource, null); 2823 } 2824 } 2825 2826 public string GetAddressHash(string address, string address2, string city, string region, string zip, string country) 2827 { 2828 return string.Concat(address, address2, city, region, zip, country); 2829 } 2830 2831 public void ShouldChangeThePageTemplate(string template) 2832 { 2833 var queryParameters = HttpUtility.ParseQueryString(Dynamicweb.Context.Current.Request.Url.Query); 2834 2835 if (queryParameters.AllKeys.Contains("LayoutTemplate") || Pageview.Page.LayoutTemplate.Contains(template)) return; 2836 2837 queryParameters.Add("LayoutTemplate", template); 2838 2839 Helpers.Redirect(Helpers.BuildUri(Helpers.GetCurrentUrl(true, true), queryParameters).ToString()); 2840 } 2841 } 2842 @{ 2843 2844 @helper RenderViewCartActions() 2845 { 2846 <div class="col-xs-12 noPadding"> 2847 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Go to checkout"), "#", "btn-default col-xs-12 col-sm-offset-8 col-sm-4 col-md-offset-9 col-md-3 gotoCheckout")) 2848 </div> 2849 } 2850 2851 @helper RenderCheckoutActions(bool showPrevious = false) 2852 { 2853 <div class="continueButton col-xs-12"> 2854 @if (showPrevious) 2855 { 2856 var previousButton = "/Default.aspx?Id=" + Pageview.Page.ID + "&amp;" + GetString("CartV2.PreviousStepButtonName") + "=true"; 2857 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Previous"), previousButton, "pull-left previousButton")) 2858 } 2859 @RenderField(FieldSettings.CreateSubmitField(Translate("Continue Checkout"), "btn-default pull-right")) 2860 </div> 2861 } 2862 2863 @helper RenderCheckoutCompleteActions(bool isCheckoutFlow = true) 2864 { 2865 var printUrl = HttpContext.Current.Request.RawUrl + "&amp;print=true"; 2866 var pdfUrl = printUrl + "&amp;pdf=true&amp;filename=Order_" + GetString("Ecom:Order.ID") + ".pdf"; 2867 2868 <div class="continueButton col-xs-12 hidden-xs"> 2869 @RenderBootstrapButton(new BootstrapButtonSettings 2870 { 2871 Label = Translate("Print"), 2872 Href = printUrl, 2873 CssClass = "btn-default pull-left print", 2874 Target = "_blank" 2875 }) 2876 @RenderBootstrapButton(new BootstrapButtonSettings 2877 { 2878 Label = Translate("Download as PDF"), 2879 Href = pdfUrl, 2880 CssClass = "btn-default pull-left dwnPdf", 2881 Target = "_blank" 2882 }) 2883 2884 @if (!isCheckoutFlow) 2885 { 2886 @RenderBootstrapButton(new BootstrapButtonSettings 2887 { 2888 Label = Translate("Back"), 2889 Href = "javascript:history.back();", 2890 CssClass = "btn-bg2 pull-right", 2891 IconCssClass = "fa-arrow-left" 2892 }) 2893 } 2894 </div> 2895 } 2896 2897 @helper RenderCartContents(List<LoopItem> orderlines, CartOutputType outputType = CartOutputType.ReadOnly, List<LoopItem> orderLinesOutOfStock = null) 2898 { 2899 orderLinesOutOfStock = orderLinesOutOfStock == null ? new List<LoopItem>() : orderLinesOutOfStock; 2900 var ulCssClass = outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart ? "cartProductsList" : "col-xs-12"; 2901 var ulCssId = outputType == CartOutputType.MiniCart ? "miniCartContainer" : ""; 2902 2903 if (outputType == CartOutputType.Editable && orderLinesOutOfStock.Any()) 2904 { 2905 <h2 class="outOfStock">@Translate("One or more items in your cart are not available")</h2> 2906 2907 <header class="showCartHeader col-sm-12 noPadding"> 2908 <div class="hidden-xs col-sm-2 col-xs-offset-4 noPadding mdAlignRight">@Translate("Unit price")</div> 2909 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty Available")</div> 2910 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty Requested")</div> 2911 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 2912 </header> 2913 2914 @:<ul class="@ulCssClass outOfStock" id="@ulCssId"> 2915 2916 foreach (var orderline in orderLinesOutOfStock) 2917 { 2918 @InternalRenderCartContentLine(orderline, outputType, true) 2919 } 2920 2921 @:</ul> 2922 } 2923 2924 if (outputType == CartOutputType.Editable && orderLinesOutOfStock.Any()) 2925 { 2926 <h2 class="outOfStock">@Translate("The following products are in stock and can be ordered")</h2> 2927 } 2928 2929 if (outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart) 2930 { 2931 <header class="showCartHeader col-sm-12 noPadding"> 2932 <div class="hidden-xs col-sm-2 col-xs-offset-4 noPadding mdAlignRight">@Translate("Unit price")</div> 2933 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty")</div> 2934 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Discount")</div> 2935 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 2936 </header> 2937 } 2938 else if (outputType == CartOutputType.MiniCart) 2939 { 2940 var totalQty = GetInteger("Ecom:Order.OrderLines.TotalProductQuantity"); // variable needed to avoid Ajax issues with the attribute value 2941 2942 // This will allow carts to be picked up by "Abandoned Carts" provider without users going to the cart 2943 if (User.IsExtranetUserLoggedIn() && GetString("Ecom:Order.Customer.Email").IsNullOrEmpty() || GetString("Ecom:Order.ShopID").IsNullOrEmpty()) 2944 { 2945 var userEmail = Pageview.User != null ? Pageview.User.Email : string.Empty; 2946 if (userEmail.IsNotNullOrEmpty()) 2947 { 2948 Dynamicweb.Ecommerce.Common.Context.Cart.CustomerEmail = userEmail; 2949 } 2950 @* 2951 TODO Fix code below because it's rendering an error in the Contacts Pop-up 2952 Dynamicweb.Ecommerce.Common.Context.Cart.ShopId = Pageview.Area.EcomShopId; 2953 Dynamicweb.Ecommerce.Common.Context.Cart.Save(); 2954 *@ 2955 } 2956 2957 @:<div> 2958 var orderMinicart = Dynamicweb.Ecommerce.Common.Context.Cart; 2959 var lastDateMinicart = (DateTime?) null; 2960 2961 if (orderMinicart != null) 2962 { 2963 var lineModifedMinicart = orderMinicart.OrderLines.Max(x => x.Modified); // Gets the latest changed date on the line, requires at least one line to be present 2964 lastDateMinicart = lineModifedMinicart > orderMinicart.Modified ? lineModifedMinicart : orderMinicart.Modified; 2965 } 2966 @:<div id="miniCart" data-quantity="@totalQty" data-orderId='@GetString("Ecom:Order.ID")' data-modifiedDate="@lastDateMinicart"> 2967 } 2968 2969 @:<ul class="@ulCssClass" id="@ulCssId"> 2970 2971 foreach (var orderline in orderlines) 2972 { 2973 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 2974 2975 if (orderLineType == OrderLineType.Product || 2976 orderLineType == OrderLineType.GiftCard || 2977 orderLineType == OrderLineType.Fixed || 2978 orderLineType == OrderLineType.PointProduct || 2979 orderLineType == OrderLineType.Discount && orderline.GetBoolean("Ecom:Order:OrderLine.Price.IsZero") || 2980 orderLineType == OrderLineType.ProductDiscount && orderline.GetBoolean("Ecom:Order:OrderLine.Price.IsZero")) 2981 { 2982 if (outputType == CartOutputType.Email) 2983 { 2984 @InternalRenderEmailCartContentLine(orderline) 2985 } 2986 else if (outputType != CartOutputType.Editable || orderLinesOutOfStock == null || !orderLinesOutOfStock.Any() || !orderLinesOutOfStock.Contains(orderline)) 2987 { 2988 @InternalRenderCartContentLine(orderline, outputType) 2989 } 2990 } 2991 } 2992 2993 if (outputType != CartOutputType.Email) 2994 { 2995 @:</ul> 2996 } 2997 if (outputType == CartOutputType.MiniCart) 2998 { 2999 var checkoutUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=" + Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "MyCart").ID + "&CartV2.GotoStep1=true"); 3000 3001 <footer class="col-xs-12"> 3002 @* The lines 231-239 have to be refactored (removed from this template) before Rizzo update TODO*@ 3003 <div class="subTotal col-xs-12 noPadding"> 3004 @Translate("Subtotal") <span class="pull-right">@RenderProductPrice(GetString("Ecom:Order.PriceWithoutDiscounts"))</span> 3005 </div> 3006 @if (GetDouble("Ecom:Order.TotalDiscount.Price") < 0) 3007 { 3008 <div class="col-xs-12 noPadding"> 3009 @Translate("Discount") <span class="pull-right">@RenderProductPrice(GetString("Ecom:Order.TotalDiscount"))</span> 3010 </div> 3011 } 3012 <div class="col-xs-12 noPadding"> 3013 @Translate("*Total") <span class="pull-right">@RenderProductPrice(GetString("Ecom:Order.Price"))</span> 3014 </div> 3015 <div class="miniCartBtns col-xs-12 noPadding"> 3016 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Show Cart"), Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("MyCart")), "btn-default pull-left")) 3017 3018 @{ 3019 var isWebServiceConnectionAvailable = Dna.Ecommerce.LiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 3020 3021 if ((isWebServiceConnectionAvailable || !ShowNoErpConnectionMessage()) && !orderLinesOutOfStock.Any()) 3022 { 3023 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Checkout"), checkoutUrl, "btn-default pull-right")) 3024 } 3025 } 3026 </div> 3027 3028 @InternalRenderOrderAmountsDisclaimer() 3029 </footer> 3030 @:</div> 3031 @:</div> 3032 @:</div> 3033 } 3034 } 3035 3036 @helper RenderCartContentsSummary(List<LoopItem> orderlines, string voucherValue, CartOutputType outputType = CartOutputType.ReadOnly) 3037 { 3038 var voucherResult = PromoCodeChecker.CheckOrderPromoCode(voucherValue); 3039 @RenderCartContentsSummary(orderlines, voucherValue, voucherResult, outputType) 3040 } 3041 3042 @helper RenderCartContentsSummary(List<LoopItem> orderlines, string voucherValue, PromoCodeInfo voucherResult, CartOutputType outputType = CartOutputType.ReadOnly) 3043 { 3044 var orderDiscount = orderlines 3045 .Where(t => t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.Discount || t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.ProductDiscount && t.GetString("Ecom:Order:OrderLine.ParentLineID").IsNullOrEmpty()) 3046 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 3047 3048 if (outputType != CartOutputType.Email) 3049 { 3050 @:<div id="totalPriceContainer" class="col-xs-12 col-sm-5 noPadding pull-right noPadding-xs"> 3051 } 3052 3053 if (voucherResult.Valid && !voucherResult.Expired && !voucherResult.Inactive && voucherValue.IsNotNullOrEmpty()) 3054 { 3055 <div class="col-xs-12 noPadding"> 3056 <div class="discountContainer col-xs-12"> 3057 <div class="row"> 3058 <span class="col-xs-8 col-sm-7 noPadding">@Translate("Voucher"): @EcommerceHelpers.GetVoucherName(voucherValue)</span> 3059 </div> 3060 </div> 3061 </div> 3062 } 3063 3064 if (GetDouble("Ecom:Order.TotalPoints") > 0) 3065 { 3066 @InternalRenderTotalAmountLine(Translate("Loyalty Points Spent"), GetString("Ecom:Order.TotalPoints"), false, outputType) 3067 } 3068 3069 if (GetDouble("Ecom:Order.RewardTotalPoints") > 0) 3070 { 3071 @InternalRenderTotalAmountLine(Translate("Loyalty Points Earned"), GetString("Ecom:Order.RewardTotalPoints"), false, outputType) 3072 } 3073 3074 if (orderDiscount < 0) 3075 { 3076 @InternalRenderTotalAmountLine(Translate("Order Savings"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true), false, outputType) 3077 } 3078 if (GetString("Ecom:Order.PriceWithoutFees.PriceFormatted") != "0.00") 3079 { 3080 @InternalRenderTotalAmountLine(Translate("Subtotal"), GetString("Ecom:Order.PriceWithoutFees.PriceFormatted"), true, outputType) 3081 } 3082 if (GetString("Ecom:Order.ShippingMethodID").IsNotNullOrEmpty()) 3083 { 3084 @InternalRenderTotalAmountLine(GetString("Ecom:Order.ShippingMethod"), GetString("Ecom:Order.ShippingFee.PriceWithoutVATFormatted"), false, outputType) 3085 } 3086 if (GetString("Ecom:Order.Taxes.Total.Price") != "0.00") 3087 { 3088 @InternalRenderTotalAmountLine(Translate("Taxes"), GetString("Ecom:Order.Taxes.Total"), false, outputType) 3089 } 3090 @InternalRenderTotalAmountLine(Translate("Total"), GetString("Ecom:Order.Price"), true, outputType) 3091 3092 if (outputType != CartOutputType.Email) 3093 { 3094 @InternalRenderOrderAmountsDisclaimer() 3095 @: </div> 3096 } 3097 } 3098 3099 @helper RenderCartSummary(List<LoopItem> orderlines) 3100 { 3101 var orderDiscount = orderlines 3102 .Where(t => t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.Discount || t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.ProductDiscount && t.GetString("Ecom:Order:OrderLine.ParentLineID").IsNullOrEmpty()) 3103 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 3104 3105 var areAddessesTheSame = AreAddressesTheSame(); 3106 3107 <h2 data-cartid="@GetString("Ecom:Order.ID")">@Translate("Order Summary")</h2> 3108 3109 if (orderlines.Any()) 3110 { 3111 var billingAndShippingAddressesTranslate = Translate("Billing & Shipping Address"); 3112 var billingAddressTranslate = Translate("Billing Address"); 3113 var shippingAddressTranslate = Translate("Shipping Address"); 3114 3115 <dl data-billingandshippingaddresses='@billingAndShippingAddressesTranslate' data-billingaddress='@billingAddressTranslate' data-shippingaddress='@shippingAddressTranslate'> 3116 @if(GetString("Ecom:Order.Customer.Name").IsNotNullOrEmpty()) { 3117 <dt class="col-xs-12 rightTitle borderBottom shippingAddressTitle"> 3118 @( areAddessesTheSame ? billingAndShippingAddressesTranslate : shippingAddressTranslate) 3119 </dt> 3120 <dd class="col-xs-12 shippingAddress"> 3121 @if(GetString("Ecom:Order.Delivery.Name").IsNotNullOrEmpty()) 3122 { 3123 @GetString("Ecom:Order.Delivery.Name")<br/> 3124 } 3125 @GetAddressFormatted(AddressSource.EcomDelivery, false, true, true, "<br/>") 3126 </dd> 3127 if (!areAddessesTheSame && GetString("Ecom:Order.Delivery.Address").IsNotNullOrEmpty()) 3128 { 3129 <dt class="col-xs-12 rightTitle billingAddressTitle"> 3130 @billingAddressTranslate 3131 </dt> 3132 <dd class="col-xs-12 billingAddress"> 3133 @GetString("Ecom:Order.Customer.Name")<br/> 3134 @GetAddressFormatted(AddressSource.EcomCustomer, false, true, true, "<br/>") 3135 </dd> 3136 } 3137 } 3138 3139 @InternalRenderCartSummaryLine(Translate("Payment Method"), GetString("Ecom:Order.PaymentMethod"), string.Empty, "paymentMethodName", false, true) 3140 3141 <dt class="col-xs-12 borderBottom orderSummaryDeta">@Translate("Order Details")</dt> 3142 <dd class="col-xs-12 osProducts"> 3143 <ul> 3144 @foreach (var orderline in orderlines) 3145 { 3146 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 3147 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 3148 3149 if (orderLineType == OrderLineType.Product || 3150 orderLineType == OrderLineType.GiftCard || 3151 orderLineType == OrderLineType.Fixed || 3152 orderLineType == OrderLineType.PointProduct || 3153 orderLineType == OrderLineType.Discount && orderline.GetBoolean("Ecom:Order:OrderLine.Price.IsZero") || 3154 orderLineType == OrderLineType.ProductDiscount && orderline.GetBoolean("Ecom:Order:OrderLine.Price.IsZero")) 3155 { 3156 <li class="col-xs-12 noPadding"> 3157 <div class="col-xs-12 noPaddingLeft"> 3158 @orderline.GetString("Ecom:Order:OrderLine.ProductName") 3159 @if (variantText.IsNotNullOrEmpty()) 3160 { 3161 <br/> 3162 <small>@variantText</small> 3163 } 3164 </div> 3165 <div> 3166 <small class="col-xs-8 noPaddingLeft">@Translate("Qty"): @orderline.GetString("Ecom:Order:OrderLine.Quantity")</small> 3167 <span class="col-xs-4 text-right noPadding">@orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVATFormatted")</span> 3168 </div> 3169 </li> 3170 } 3171 } 3172 </ul> 3173 </dd> 3174 3175 @if (GetDouble("Ecom:Order.TotalPoints") > 0) 3176 { 3177 @InternalRenderCartSummaryLine(Translate("Loyalty Points Spent"), GetString("Ecom:Order.TotalPoints"), "orderSummaryPointsSpent") 3178 } 3179 3180 @if (GetDouble("Ecom:Order.RewardTotalPoints") > 0) 3181 { 3182 @InternalRenderCartSummaryLine(Translate("Loyalty Points Earned"), GetString("Ecom:Order.RewardTotalPoints"), "orderSummaryPointsEarned") 3183 } 3184 3185 @if (orderDiscount < 0) 3186 { 3187 @InternalRenderCartSummaryLine(Translate("Order Savings"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true), "orderSummaryOrderSavings") 3188 } 3189 3190 @InternalRenderCartSummaryLine(Translate("Subtotal"), GetString("Ecom:Order.PriceWithoutFees.PriceFormatted"), "orderSummarySubtotal", string.Empty, true) 3191 3192 @InternalRenderCartSummaryLine(GetString("Ecom:Order.ShippingMethod"), GetString("Ecom:Order.ShippingFee.PriceWithoutVATFormatted"), "orderSummaryShippingName", "orderSummaryShippingPrice", false, true) 3193 3194 @if (GetString("Ecom:Order.Taxes.Total.Price") != "0.00") 3195 { 3196 @InternalRenderCartSummaryLine(Translate("Taxes"), GetString("Ecom:Order.Taxes.Total"), "orderSummaryTaxes") 3197 } 3198 3199 @InternalRenderCartSummaryLine(Translate("Total"), GetString("Ecom:Order.OrderLines.Total.PriceWithoutVAT"), "", "orderSummaryTotal", true) 3200 </dl> 3201 3202 @InternalRenderOrderAmountsDisclaimer() 3203 3204 <div id="editOrderButton" class="col-xs-12 text-center"> 3205 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Edit order"), Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "MyCart").ID), "btn-outline")) 3206 </div> 3207 } 3208 } 3209 3210 @helper RenderVoucherField() 3211 { 3212 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 3213 var voucherCodeErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderVoucherCode.ErrorMessage"); 3214 3215 3216 var voucherResult = PromoCodeChecker.CheckOrderPromoCode(voucherCode); 3217 var voucherFieldValue = !voucherResult.Valid ? string.Empty : voucherCode; 3218 3219 3220 <h2>@Translate("Voucher Code")</h2> 3221 <div id="promoCodeContainer" class="DMForms col-xs-12 noPadding stepContainer" data-error="@voucherCodeErrorMessage"> 3222 @if (!voucherResult.Valid || voucherResult.Expired || voucherResult.Inactive) 3223 { 3224 @RenderField(new FieldSettings { Type = FieldType.Text, Label = Translate("Enter a Voucher Code"), SystemName = "EcomOrderVoucherCode", Value = GetString("Ecom:Order.Customer.VoucherCode"), IncludeWrapper = false}) 3225 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Apply"), string.Empty, "btn-default submitVoucher")) 3226 3227 if (voucherCode.IsNotNullOrEmpty()) 3228 { 3229 <div class="col-xs-12 noPadding voucherError"> 3230 @Translate("Voucher does not exist") 3231 </div> 3232 } 3233 } 3234 else 3235 { 3236 <div class="promoCodeApplied col-xs-12"> 3237 @Translate("Promo Code"): <span>@voucherCode</span> 3238 <a class="removeVoucher" href="javascript:void(0)"> 3239 @RenderIcon("fa-times", Translate("Remove")) 3240 </a> 3241 </div> 3242 } 3243 </div> 3244 } 3245 3246 @helper RenderRegions(List<LoopItem> countries) 3247 { 3248 var locations = new Dictionary<string, dynamic> 3249 { 3250 {"locations", new Dictionary<string, dynamic>()} 3251 }; 3252 3253 locations["locations"].Add("Countries", new List<dynamic>()); 3254 3255 foreach (var ct in countries) 3256 { 3257 var regionsList = ct.GetLoop("Regions"); 3258 var countryDict = new Dictionary<string, dynamic>(); 3259 var countryKey = new Dictionary<string, dynamic> 3260 { 3261 {"id", ct.GetString("Ecom:Country.Code2")}, {"regions", new List<dynamic>()} 3262 }; 3263 3264 3265 foreach (var region in regionsList.OrderBy(s => s.GetString("Ecom:Region.Name"))) 3266 { 3267 var regionsDict = new Dictionary<string, string> 3268 { 3269 {"name", region.GetString("Ecom:Region.Name")}, 3270 {"code", region.GetString("Ecom:Region.RegionCode")} 3271 }; 3272 3273 countryKey["regions"].Add(regionsDict); 3274 } 3275 countryDict.Add("country", countryKey); 3276 locations["locations"]["Countries"].Add(countryDict); 3277 } 3278 var productJson = new JavaScriptSerializer().Serialize(locations); 3279 @productJson 3280 } 3281 3282 @helper RenderCheckoutGoogleTag(List<LoopItem> orderlines,string eventName) 3283 { 3284 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 3285 var coupon = voucherCode.IsNotNullOrEmpty() ? string.Concat(",\"coupon\": \"",voucherCode,"\"") : ""; 3286 3287 if ((Pageview.Area.Item["GoogleAnalytics"] ?? "").ToString().IsNotNullOrEmpty() && orderlines.Any()) 3288 { 3289 var objectChar = "{"; 3290 <text> 3291 gtag('event', '@eventName', { 3292 @if (eventName == "purchase") 3293 { 3294 <text> 3295 "value": @GetDouble("Ecom:Order.Price.Price").ToString(CultureInfo.InvariantCulture), 3296 "currency": "@Dynamicweb.Ecommerce.Common.Context.Currency.Code", 3297 "tax": @GetDouble("Ecom:Order.Taxes.Total").ToString(CultureInfo.InvariantCulture), 3298 "shipping": @GetDouble("Ecom:Order.ShippingFee.Price").ToString(CultureInfo.InvariantCulture), 3299 </text> 3300 } 3301 "items": [ 3302 @foreach (var orderline in orderlines.Where(ol => ol.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.Product)) 3303 { 3304 <text> 3305 @objectChar 3306 "id": "@(orderline.GetString("Ecom:Order:OrderLine.ProductID"))", 3307 "name": "@HttpUtility.JavaScriptStringEncode(orderline.GetString("Ecom:Order:OrderLine.ProductName"))", 3308 "variant": "@HttpUtility.JavaScriptStringEncode(orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"))", 3309 "quantity": @orderline.GetInteger("Ecom:Order:OrderLine.Quantity"), 3310 "price": '@(orderline.GetDouble("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.Price").ToString(CultureInfo.InvariantCulture))' 3311 } 3312 </text> 3313 objectChar = ",{"; 3314 } 3315 ] 3316 @coupon 3317 }); 3318 </text> 3319 } 3320 } 3321 3322 @helper RenderAddressTextContainer(AddressSource addressSource, string wrapperId, string addressId, bool isShippingEditable, bool isBillingReadOnly) 3323 { 3324 var isEcomDelivery = addressSource == AddressSource.EcomDelivery; 3325 var addressHash = GetAddressHash(addressSource); 3326 var editTranslate = isBillingReadOnly && !isShippingEditable ? Translate("Edit Address for Current Order Only") : Translate("Edit"); 3327 3328 if (isEcomDelivery && GetString("Ecom:Order.Delivery.Name").IsNotNullOrEmpty()) 3329 { 3330 @(string.Concat(Translate("Attn.")," ",GetString("Ecom:Order.Delivery.Name"))) 3331 } 3332 <div data-hash="@addressHash" id="@wrapperId"> 3333 @GetAddressFormatted(addressSource, false, true, true, "<br/>") 3334 </div> 3335 if (isEcomDelivery) 3336 { 3337 @RenderHtmlElementBetweenEachString(new List<string>{GetString("Ecom:Order.Customer.Email"),GetString("Ecom:Order.Customer.Phone")}) 3338 } 3339 <a class="editCurrentAddress" href="javascript:void(0);">@RenderIcon("fa-edit", editTranslate)</a> 3340 } 3341 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 3342 @using Dynamicweb.Rendering 3343 @using System 3344 @using Dynamicweb.Security.UserManagement 3345 @using System.Collections.Generic 3346 @using Dna.Frontend.Forms 3347 @using Dynamicweb.Forms 3348 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 3349 @using Dynamicweb.Rendering 3350 @using System.Collections.Generic 3351 @using Dna.Frontend.Forms 3352 @using Dynamicweb.Forms 3353 @{ 3354 3355 @helper InternalRenderGiftCardAmount(bool isGiftCard = false, string productPrice = "", string productId = "") 3356 { 3357 if (isGiftCard) 3358 { 3359 var giftCardAmountFieldSettings = new FieldSettings 3360 { 3361 Type = FieldType.Number, 3362 SystemName = "Amount", 3363 Id = "Amount" + productId, 3364 Placeholder = Translate("amount"), 3365 Value = productPrice, 3366 IncludeWrapper = true, 3367 WrapperCssClass = "pull-left giftCardAmount", 3368 Attributes = new Dictionary<string, string> 3369 { 3370 {"step", "0.01"}, 3371 {"min", "0.01"} 3372 } 3373 }; 3374 @RenderField(giftCardAmountFieldSettings) 3375 } 3376 } 3377 3378 } 3379 @{ 3380 @helper RenderProductReviewsCount(int count = -1) 3381 { 3382 if (ShowReviews() && ShowRatings()) 3383 { 3384 if (count == -1) 3385 { 3386 count = GetInteger("Comments.Count"); 3387 } 3388 <span>@string.Concat(count, " ", count == 1 ? Translate("Review") : Translate("Reviews"))</span> 3389 } 3390 3391 } 3392 @helper RenderRating(double rating) 3393 { 3394 if (ShowRatings()) 3395 { 3396 <ul class="rating"> 3397 @for (var s = 5; s > 0; s--) 3398 { 3399 var cssClass = string.Empty; 3400 var iconCssClass = "fa-star"; 3401 3402 if (Math.Abs(s - Math.Ceiling(rating)) <= 0) 3403 { 3404 cssClass = "class='star'"; 3405 iconCssClass = !(Math.Abs(rating - Math.Round(rating)) <= 0) ? "fa-star-half-o" : "fa-star"; 3406 } 3407 else if (Math.Ceiling(rating) < s) 3408 { 3409 iconCssClass = "fa-star-o"; 3410 } 3411 3412 <li data-star="@s" @cssClass> 3413 @RenderIcon(iconCssClass) 3414 </li> 3415 } 3416 </ul> 3417 } 3418 } 3419 3420 @helper RenderStockStatus(string stockStatus, int productType = 0) 3421 { 3422 // Only show if it's not a Service or Gift Card 3423 if (productType != 1 && productType != 3) 3424 { 3425 <div class="col-xs-12 noPadding stockStatus"> 3426 @RenderIcon(stockStatus, Translate("Stock")) 3427 </div> 3428 } 3429 } 3430 3431 @helper RenderFavorites(bool productIsFavorite, string productId, string variantId, string productLanguage, bool variantCombinations = false, bool iconOnly = false) 3432 { 3433 // Favorites 3434 var favoritesUrl = "/Default.aspx?Id=" + Pageview.Page.ID + "&amp;CC{{favoriteAction}}MyLists=" + productId + "&amp;CC{{favoriteAction}}ListVariantID=" + variantId + "&amp;CC{{favoriteAction}}ListLanguageID=" + productLanguage; 3435 var addToFavorites = favoritesUrl.Replace("{{favoriteAction}}", "AddTo"); 3436 var removeFromFavorites = favoritesUrl.Replace("{{favoriteAction}}", "RemoveFrom"); 3437 var favoriteUrl = productIsFavorite ? removeFromFavorites : addToFavorites; 3438 var iconLabel = !iconOnly ? Translate(productIsFavorite ? "Remove From List" : "Add to List") : string.Empty; 3439 if (User.IsExtranetUserLoggedIn() && 3440 Dynamicweb.Environment.ExecutingContext.IsFrontEnd() && 3441 !variantCombinations) 3442 { 3443 <a class="btn-gold-outline favorite" data-add="@addToFavorites" data-remove="@removeFromFavorites" data-favorite="@productIsFavorite" data-user="@User.IsExtranetUserLoggedIn()" data-addText='@Translate("Add to List")' data-removeText='@Translate("Remove from List")' href="@favoriteUrl"> 3444 @RenderIcon(productIsFavorite ? "fa-heart" : "fa-heart-o", iconLabel) 3445 </a> 3446 } 3447 } 3448 3449 @helper RenderQuantitySelector(bool variantGroupsExistList, int productStock, int productType = 0, string productId = "") 3450 { 3451 if (Pageview.Area.Item["ShowQuantityField"].ToString() == "True") 3452 { 3453 @InternalRenderQuantityField(productStock, productStock, 1, string.Empty, 10, false, variantGroupsExistList, productType, productId) 3454 } 3455 else 3456 { 3457 var quantityTextFieldSettings = new FieldSettings 3458 { 3459 Type = FieldType.Text, 3460 Value = "1", 3461 SystemName = "quantity", 3462 Id = "quantity" + productId, 3463 Attributes = new Dictionary<string, string> 3464 { 3465 {"maxlength", "5"}, 3466 {"data-productStock", productStock.ToString()}, 3467 {"data-outofstock", Translate("Out of stock")}, 3468 {"data-stocktranslate", Translate("The current stock is")} 3469 } 3470 }; 3471 3472 if (productType != 1 && productType != 3) 3473 { 3474 quantityTextFieldSettings.Type = FieldType.Number; 3475 quantityTextFieldSettings.Label = Translate("Qty"); 3476 quantityTextFieldSettings.CssClass = "quantityInput hidden"; 3477 } 3478 else 3479 { 3480 quantityTextFieldSettings.Type = FieldType.Hidden; 3481 } 3482 @RenderField(quantityTextFieldSettings) 3483 } 3484 } 3485 3486 @helper RenderProductCompare(int productType, string productId, string variantId = "", string productLanguage = "") 3487 { 3488 var isGiftCard = productType == 3; 3489 3490 if (!isGiftCard) 3491 { 3492 var compareLink = productId; 3493 compareLink += productLanguage.IsNotNullOrEmpty() ? "$" + productLanguage : ""; 3494 compareLink += variantId.IsNotNullOrEmpty() ? "$" + variantId : ""; 3495 const int compareLimit = 3; 3496 3497 @RenderField(new FieldSettings 3498 { 3499 Type = FieldType.Checkbox, 3500 Label = Translate("Add to compare"), 3501 SystemName = "addToCompare_" + productId, 3502 IncludeWrapper = true, 3503 WrapperElement = "div", 3504 WrapperCssClass = "addToCompare", 3505 Attributes = new Dictionary<string, string> 3506 { 3507 {"data-link", compareLink}, 3508 {"data-maxcompare", string.Concat(Translate("Maximum to compare"), ": ", compareLimit)} 3509 } 3510 }) 3511 } 3512 } 3513 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 3514 @using Dynamicweb.Rendering 3515 @using Dna.Validation 3516 @using Dynamicweb.Core 3517 @helper RenderBreadcrumb() { 3518 if (GetString("DwNavigation(breadCrumbsMenu2)").IsNotNullOrEmpty()) 3519 { 3520 <nav id="breadMenuContainer" aria-label="breadcrumb" role="navigation" class="col-xs-12 noPadding"> 3521 <div id="breadCrumbsMenu2" class="dwnavigation" settings="startlevel:1;endlevel:6;template:breadCrumbs.xslt;expandmode:Pathonly;includemode:all;id:breadCrumbsMenu2;"></div> 3522 @if (Sanitize.Parameter("productid").IsNotNullOrEmpty()) 3523 { 3524 @:&nbsp;»&nbsp; 3525 @GetString("Title") 3526 } 3527 </nav> 3528 } 3529 } 3530 @helper RenderPageTitle() { 3531 var heading = GetString("Item.Page.PageHeading") ; 3532 var title = heading.IsNotNullOrEmpty() ? heading : GetString("DwPageName") ; 3533 3534 <div class="h1">@title</div> 3535 } 3536 @helper RenderCentralContent(string rightClass = "") { 3537 if (GetString("DwContent(centralContent)").IsNotNullOrEmpty()) 3538 { 3539 <div id="centralContent" class="dwcontent @rightClass" title="Page content" settings="grid:true;default:true;template:StandardParagraph.cshtml;limit:StandardParagraph.cshtml;id:homeContent"></div> 3540 } 3541 } 3542 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 3543 @using System 3544 @using Dynamicweb.Rendering 3545 @using System.Linq 3546 @using Dna.UrlServices 3547 @using Dynamicweb.Frontend 3548 3549 @functions 3550 { 3551 public int GetParagraphIdFromCc() 3552 { 3553 var sendOrderPageId = GetPageIdByNavigationTag("SendOrder"); 3554 var paragraphCollection = Dynamicweb.Services.Paragraphs.GetParagraphsByPageId(sendOrderPageId); 3555 var paragraphId = paragraphCollection != null ? paragraphCollection.Where(p => p.ModuleSystemName == "eCom_CustomerCenter" && p.ShowParagraph).Select(p => p.ID).FirstOrDefault() : 0; 3556 3557 return paragraphId; 3558 } 3559 3560 public bool IsProductOrderable(LoopItem product = null) 3561 { 3562 return IsProductStatus("Orderable", product); 3563 } 3564 3565 public bool IsProductVisible(LoopItem product = null) 3566 { 3567 return IsProductStatus("Visible", product); 3568 } 3569 3570 public bool IsProductWebAvailable(LoopItem product = null) 3571 { 3572 return IsProductOrderable(product) || IsProductVisible(product); 3573 } 3574 3575 public bool IsProductStatus(string fieldValue, LoopItem product = null) 3576 { 3577 var user = Pageview.User; 3578 var customerType = user != null ? user.CustomFieldValues.First(fv => fv.CustomField.SystemName == "AccessUser_CustomerType").Value.ToString() : ""; 3579 var defaultSettings = Pageview.Area.Item["AnonymousCustomerType"]; 3580 var anonymousUser = user == null && defaultSettings != null ? defaultSettings.ToString() : ""; 3581 3582 var productB2BStatus = product != null ? product.GetString("Ecom:Product:Field.B2BStatus.Value") : GetString("Ecom:Product:Field.B2BStatus.Value"); 3583 var productB2BEligible = product != null ? product.GetString("Ecom:Product:Field.B2BLegEligibleStatus.Value") : GetString("Ecom:Product:Field.B2BLegEligibleStatus.Value"); 3584 var productGLMPStatus = product != null ? product.GetString("Ecom:Product:Field.GLMPStatus.Value") : GetString("Ecom:Product:Field.GLMPStatus.Value"); 3585 var productB2CStatus = product != null ? product.GetString("Ecom:Product:Field.B2CStatus.Value") : GetString("Ecom:Product:Field.B2CStatus.Value"); 3586 var productB2CBoatlifter = product != null ? product.GetString("Ecom:Product:Field.B2CBoatlifterStatus.Value") : GetString("Ecom:Product:Field.B2CBoatlifterStatus.Value"); 3587 3588 var userB2B = (anonymousUser == "B2B" || customerType == "B2B") && productB2BStatus.Equals(fieldValue); 3589 var userB2BLegEligible = (anonymousUser == "B2BLegEligible" || customerType == "B2BLegEligible") && productB2BEligible.Equals(fieldValue); 3590 var userGlmp = (anonymousUser == "GLMP" || customerType == "GLMP") && productGLMPStatus.Equals(fieldValue); 3591 var userB2C = (anonymousUser == "B2C" || customerType == "B2C") && productB2CStatus.Equals(fieldValue); 3592 var userB2CBoatLifter = (anonymousUser == "B2CBoatlifter" || customerType == "B2CBoatlifter") && productB2CBoatlifter.Equals(fieldValue); 3593 3594 return userB2B || userB2BLegEligible || userB2C || userGlmp || userB2CBoatLifter; 3595 } 3596 3597 public bool IsBoatlifterSite() 3598 { 3599 var websites = Pageview.Area.Item["Websites"].ToString(); 3600 3601 return websites == "Boatlifter"; 3602 } 3603 3604 public string GetWebsiteDomain(PageView pageview) 3605 { 3606 return Dna.Hewitt.Helpers.GetWebsiteDomain(pageview); 3607 } 3608 } 3609 3610 @helper RenderIFrameContent() 3611 { 3612 @GetString("Item.IFrame") 3613 } 3614 @helper RenderUserIsBlockedMessage() 3615 { 3616 <div class="homeAccountError"> 3617 <h2>@Translate("Account is blocked, please contact Customer Service (800) 544-2067")</h2> 3618 </div> 3619 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 3620 @using System 3621 @using System.Linq 3622 @using System.Collections.Generic 3623 @using System.Globalization 3624 @using System.Web 3625 @using Dynamicweb.Core 3626 @using Dynamicweb.Forms 3627 @using Dynamicweb.Rendering 3628 @using Dynamicweb.Frontend 3629 @using Dynamicweb.Ecommerce.Orders 3630 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 3631 @using Dynamicweb.Security.UserManagement 3632 @using Dna.Frontend 3633 @using Dna.Frontend.Forms 3634 @using Dna.Frontend.UI 3635 @using Dna.UrlServices 3636 @using Dna.Validation 3637 @using Dynamicweb.Ecommerce 3638 @{ 3639 @helper RenderCheckoutCompleteActionsCustom(bool isCheckoutFlow = true, int sendOrderPageId = 0, string orderId = "") 3640 { 3641 var printUrl = HttpContext.Current.Request.RawUrl + "&amp;print=true"; 3642 var pdfUrl = printUrl + "&amp;pdf=true&amp;filename=Order_" + orderId + ".pdf"; 3643 var sendOrderParagraphId = GetParagraphIdFromCc(); 3644 var addressPopupHref = "/Default.aspx?ID=" + GetPageIdByNavigationTag("OrderEmailAddressesPopup"); 3645 var resendOrder = SearchEngineFriendlyURLs.GetFriendlyUrl(sendOrderPageId) + "?CC" + sendOrderParagraphId + "=Resend&OrderID=" + orderId; 3646 <div class="checkoutActions continueButton col-xs-12 hidden-xs"> 3647 @RenderBootstrapButton(new BootstrapButtonSettings 3648 { 3649 Label = Translate(" Print"), 3650 Href = printUrl, 3651 CssClass = "btn-default pull-left print", 3652 Target = "_blank", 3653 IconCssClass = "fa-print" 3654 }) 3655 @RenderBootstrapButton(new BootstrapButtonSettings 3656 { 3657 Label = Translate(" Download as PDF"), 3658 Href = pdfUrl, 3659 CssClass = "btn-default pull-left dwnPdf", 3660 Target = "_blank", 3661 IconCssClass = "fa-download" 3662 }) 3663 @if (User.IsExtranetUserLoggedIn() || IsBoatlifterSite()) 3664 { 3665 @RenderBootstrapButton(new BootstrapButtonSettings 3666 { 3667 Label = Translate(" Email Order"), 3668 Href = addressPopupHref, 3669 CssClass = "btn-default pull-left emailResend", 3670 IconCssClass = "fa-envelope", 3671 Attributes = new Dictionary<string, string> 3672 { 3673 {"data-resend-href", resendOrder} 3674 } 3675 }) 3676 } 3677 @if (!isCheckoutFlow) 3678 { 3679 @RenderBootstrapButton(new BootstrapButtonSettings 3680 { 3681 Label = Translate("Back"), 3682 Href = "javascript:history.back();", 3683 CssClass = "btn-bg2 pull-right", 3684 IconCssClass = "fa-arrow-left" 3685 }) 3686 } 3687 3688 </div> 3689 } 3690 @helper RenderCartContentsCustom(List<LoopItem> orderlines, CartOutputType outputType = CartOutputType.ReadOnly) 3691 { 3692 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 3693 var ulCssClass = outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart ? "cartProductsList" : "col-xs-12"; 3694 var ulCssId = outputType == CartOutputType.MiniCart ? "miniCartContainer" : ""; 3695 var isB2BRetailPrices = isB2B && (HttpContext.Current.Request.Cookies["isRetailPrice"]?.Value ?? "false").Equals("true") && (outputType == CartOutputType.Editable || outputType == CartOutputType.MiniCart); 3696 var unitPriceLabel = Translate("Unit price"); 3697 var hideSubTotal = isB2BRetailPrices ? "hidden" : ""; 3698 var headerUnitPrice = isB2B && !isB2BRetailPrices ? Translate("Dealer price") : unitPriceLabel; 3699 3700 if (outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart && orderlines.Any()) 3701 { 3702 <div class="showCartHeader col-sm-12 noPadding"> 3703 <div class="hidden-xs col-sm-2 col-xs-offset-6 noPadding mdAlignRight">@headerUnitPrice</div> 3704 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty")</div> 3705 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 3706 </div> 3707 } 3708 else if (outputType == CartOutputType.MiniCart) 3709 { 3710 var totalQty = GetInteger("Ecom:Order.OrderLines.TotalProductQuantity"); // variable needed to avoid Ajax issues with the attribute value 3711 3712 // This will allow carts to be picked up by "Abandoned Carts" provider without users going to the cart 3713 if (Dynamicweb.Ecommerce.Common.Context.Cart != null && (User.IsExtranetUserLoggedIn() && GetString("Ecom:Order.Customer.Email").IsNullOrEmpty() || GetString("Ecom:Order.ShopID").IsNullOrEmpty())) 3714 { 3715 var userEmail = Pageview.User != null ? Pageview.User.Email : string.Empty; 3716 if (userEmail.IsNotNullOrEmpty()) 3717 { 3718 Dynamicweb.Ecommerce.Common.Context.Cart.CustomerEmail = userEmail; 3719 } 3720 @* 3721 TODO Fix code below because it's rendering an error in the Contacts Pop-up 3722 Dynamicweb.Ecommerce.Common.Context.Cart.ShopId = Pageview.Area.EcomShopId; 3723 Dynamicweb.Ecommerce.Common.Context.Cart.Save(); 3724 *@ 3725 } 3726 3727 @:<div> 3728 var orderMinicart = Dynamicweb.Ecommerce.Common.Context.Cart; 3729 var lastDateMinicart = (DateTime?) null; 3730 3731 if (orderMinicart != null) 3732 { 3733 var lineModifedMinicart = orderMinicart.OrderLines.Max(x => x.Modified); // Gets the latest changed date on the line, requires at least one line to be present 3734 lastDateMinicart = lineModifedMinicart > orderMinicart.Modified ? lineModifedMinicart : orderMinicart.Modified; 3735 } 3736 @:<div id="miniCart" data-quantity="@totalQty" data-orderId='@GetString("Ecom:Order.ID")' data-modifiedDate="@lastDateMinicart"> 3737 } 3738 3739 @:<ul class="@ulCssClass" id="@ulCssId"> 3740 3741 foreach (var orderline in orderlines) 3742 { 3743 if (orderline.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Discount && orderline.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Tax) 3744 { 3745 if (outputType == CartOutputType.Email) 3746 { 3747 @InternalRenderEmailCartContentLineCustom(orderline) 3748 } 3749 else 3750 { 3751 @InternalRenderCartContentLineCustom(orderline, outputType) 3752 } 3753 } 3754 } 3755 if (outputType != CartOutputType.Email) 3756 { 3757 @:</ul> 3758 } 3759 if (outputType == CartOutputType.MiniCart) 3760 { 3761 var myCartPageUrl = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("MyCart")); 3762 var orderDiscount = orderlines 3763 .Where(t => t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.Discount || t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.ProductDiscount && t.GetString("Ecom:Order:OrderLine.ParentLineID").IsNullOrEmpty()) 3764 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 3765 3766 <footer class="col-xs-12"> 3767 @if (orderDiscount < 0) 3768 { 3769 <div class="col-xs-12 noPadding"> 3770 @Translate("Discount") <span class="pull-right">@RenderProductPrice(Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true))</span> 3771 </div> 3772 } 3773 <div class="subTotal col-xs-12 noPadding @hideSubTotal"> 3774 *@Translate("Subtotal") <span class="pull-right">@RenderProductPrice(GetString("Ecom:Order.OrderLines.Total.Price"))</span> 3775 </div> 3776 <div class="miniCartBtns col-xs-12 noPadding"> 3777 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Show Cart"), string.Concat(myCartPageUrl, "?CartV2.GotoStep0=true"), "btn-default pull-left")) 3778 3779 @{ 3780 var isWebServiceConnectionAvailable = Dna.Ecommerce.LiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 3781 3782 if ((isWebServiceConnectionAvailable || !ShowNoErpConnectionMessage())) 3783 { 3784 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Checkout"), string.Concat(myCartPageUrl, "?CartV2.GotoStep1=true"), "btn-default pull-right")) 3785 } 3786 } 3787 </div> 3788 3789 @InternalRenderOrderAmountsDisclaimerCustom(orderlines, isB2B) 3790 </footer> 3791 @:</div> 3792 @:</div> 3793 @:</div> 3794 } 3795 } 3796 @helper RenderCartContentsCustom(Order order, OrderLineCollection orderlines, CartOutputType outputType = CartOutputType.ReadOnly) 3797 { 3798 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 3799 var ulCssClass = outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart ? "cartProductsList" : "col-xs-12"; 3800 var ulCssId = outputType == CartOutputType.MiniCart ? "miniCartContainer" : ""; 3801 var headerUnitPrice = isB2B ? Translate("Dealer price") : Translate("Unit price"); 3802 3803 if (outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart && orderlines.Any()) 3804 { 3805 <div class="showCartHeader col-sm-12 noPadding"> 3806 <div class="hidden-xs col-sm-2 col-xs-offset-6 noPadding mdAlignRight">@headerUnitPrice</div> 3807 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty")</div> 3808 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 3809 </div> 3810 } 3811 3812 @:<ul class="@ulCssClass" id="@ulCssId"> 3813 3814 foreach (var orderline in orderlines) 3815 { 3816 if (orderline.OrderLineType != OrderLineType.Discount && orderline.OrderLineType != OrderLineType.Tax) 3817 { 3818 @InternalRenderCartContentLineCustom(order, orderline, outputType) 3819 } 3820 } 3821 if (outputType != CartOutputType.Email) 3822 { 3823 @:</ul> 3824 } 3825 } 3826 @helper InternalRenderCartContentLineCustom(LoopItem orderline, CartOutputType outputType) 3827 { 3828 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 3829 var productStock = 999999; 3830 var productAvailableAmount = 999999; 3831 var productQuantity = orderline.GetInteger("Ecom:Order:OrderLine.Quantity"); 3832 var productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 3833 var variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 3834 var productName = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 3835 var productNumber = orderline.GetString("Ecom:Order:OrderLine.ProductNumber"); 3836 var productImage = Dna.Hewitt.Images.GetHewittImagePath(orderline); 3837 var imageUrl = Images.GetImage(productImage, 95, 95); 3838 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 3839 var isDiscountOrderline = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount") || orderline.GetString("Ecom:Order:OrderLine.ParentLineID").IsNotNullOrEmpty(); 3840 var productUrl = isDiscountOrderline ? string.Empty : SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=" + Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "Products").ID + "&GroupID=" + orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID") + "&ProductID=" + productId + (variantId.IsNotNullOrEmpty() ? string.Concat("&VariantID=", variantId) : string.Empty)); 3841 var figureClass = outputType == CartOutputType.MiniCart ? "text-center col-xs-3 noPadding" : "text-center col-xs-4"; 3842 var prodContainerClass = outputType == CartOutputType.MiniCart ? "col-xs-9 noPaddingRight" : "col-xs-8 prodName noPadding"; 3843 prodContainerClass = string.Concat(prodContainerClass, isDiscountOrderline ? outputType == CartOutputType.MiniCart ? " col-xs-offset-3" : " col-xs-offset-4" : string.Empty); 3844 var productFriendlyUrl = string.Concat(Helpers.GetCurrentUrl(true), productUrl); 3845 var shareFacebookUrl = string.Concat("https://www.facebook.com/sharer/sharer.php?u=",productFriendlyUrl); 3846 var shareTwitterUrl = string.Concat("https://twitter.com/home?status=", productFriendlyUrl); 3847 var headerUnitPrice = isB2B ? Translate("Dealer price:") : Translate("Unit price"); 3848 var isB2BRetailPrices = isB2B && (HttpContext.Current.Request.Cookies["isRetailPrice"]?.Value ?? "false").Equals("true") && (outputType == CartOutputType.Editable || outputType == CartOutputType.MiniCart); 3849 var isPdfRequest = Sanitize.Parameter("pdf").IsNotNullOrEmpty(); 3850 var imageSettings = new ImageSettings 3851 { 3852 Source = imageUrl, 3853 AltText = productName, 3854 Href = productUrl, 3855 IncludeWrapper = true, 3856 WrapperElement = Sanitize.Parameter("print").IsNotNullOrEmpty() ? "div" : "figure", 3857 WrapperCssClass = figureClass 3858 }; 3859 var orderlineId = orderline.GetString("Ecom:Order:OrderLine.Id"); 3860 var liClass = string.Concat("col-xs-12 col-sm-", outputType == CartOutputType.MiniCart ? "12" : "6" , " noPaddingLeft noPadding-xs"); 3861 var h2Class = outputType == CartOutputType.MiniCart && isDiscountOrderline && productId.IsNullOrEmpty() ? "col-xs-9 noPadding" : ""; 3862 <li class="col-xs-12 noPadding" data-facebook="@shareFacebookUrl" data-twitter="@shareTwitterUrl" data-isdiscount="@isDiscountOrderline"> 3863 <div class="@liClass"> 3864 @if (!isDiscountOrderline) 3865 { 3866 @RenderImage(imageSettings) 3867 } 3868 3869 <div class="@prodContainerClass"> 3870 <h2 class="@h2Class"> 3871 @if (isDiscountOrderline) 3872 { 3873 <strong>@productName</strong> 3874 } 3875 else 3876 { 3877 <a href="@productUrl"> 3878 <strong>@productName</strong> 3879 @if (variantText.IsNotNullOrEmpty()) 3880 { 3881 <br/> 3882 <small>@variantText</small> 3883 } 3884 </a> 3885 } 3886 </h2> 3887 @if (outputType == CartOutputType.MiniCart) 3888 { 3889 if (isDiscountOrderline && productId.IsNullOrEmpty()) 3890 { 3891 <span class="col-xs-3 noPadding text-right">@RenderProductPrice(orderline.GetString("Ecom:Order:OrderLine.TotalPrice"))</span> 3892 } 3893 else 3894 { 3895 <span class="col-xs-12 noPadding"> 3896 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 3897 { 3898 <strong>@Translate("Qty"): </strong> 3899 @orderline.GetString("Ecom:Order:OrderLine.Quantity") 3900 } 3901 <span class="pull-right">@RenderProductPrice(isB2BRetailPrices ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.GetDouble("Ecom:Product.DBPrice") * orderline.GetDouble("Ecom:Order:OrderLine.Quantity")) : orderline.GetString("Ecom:Order:OrderLine.TotalPrice"))</span> 3902 </span> 3903 } 3904 } 3905 else if (productNumber.IsNotNullOrEmpty() && outputType != CartOutputType.MiniCart) 3906 { 3907 <div class="itemDetails"> 3908 @Translate("Item number"): @productNumber 3909 </div> 3910 } 3911 @if (outputType != CartOutputType.MiniCart) 3912 { 3913 foreach (LoopItem item in orderline.GetLoop("Order.OrderLineFields").Where(of => of.GetString("Ecom:Order:OrderLine.OrderLineField.Name").Equals("Note", StringComparison.InvariantCultureIgnoreCase))) 3914 { 3915 3916 var orderlinefieldName = item.GetString("Ecom:Order:OrderLine.OrderLineField.Name"); 3917 var orderlinefieldValue = item.GetString("Ecom:Order:OrderLine.OrderLineField.Value"); 3918 3919 <div class="orderlineNote"> 3920 @if (!orderlinefieldValue.IsNotNullOrEmpty() && !isPdfRequest) 3921 { 3922 <div> 3923 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Add Note")</a> 3924 </div> 3925 } 3926 else if (orderlinefieldValue.IsNotNullOrEmpty()) 3927 { 3928 <div> 3929 <strong>@orderlinefieldName:</strong> @orderlinefieldValue<br/> 3930 </div> 3931 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Edit Note")</a> 3932 } 3933 </div> 3934 if (outputType == CartOutputType.Editable) 3935 { 3936 <div style="display: none"> 3937 <div id="edit-note@(orderlineId)" style="width: 460px;"> 3938 <form class="cartChange" method="POST" action="@SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> 3939 <h2>@Translate("Product Note")</h2> 3940 @orderlinefieldName:<br/> 3941 @RenderField(new FieldSettings 3942 { 3943 Type = FieldType.Text, 3944 SystemName = item.GetString("Ecom:Order:OrderLine.OrderLineField.InputTextField.Name"), 3945 Value = item.GetString("Ecom:Order:OrderLine.OrderLineField.Value"), 3946 Attributes = new Dictionary<string, string> 3947 { 3948 {"maxlength", "80"}, 3949 {"data-errorMessage", Translate("Please limit your Notes to a maximum of 80 characters")} 3950 } 3951 }) <br/> 3952 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"), "btn btn-bg"))<br/> 3953 </form> 3954 </div> 3955 </div> 3956 } 3957 } 3958 } 3959 </div> 3960 3961 </div> 3962 3963 @if (outputType != CartOutputType.MiniCart) 3964 { 3965 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 3966 var tempCssClass = !isDiscountOrderline ? "noPadding" : string.Empty; 3967 var totalPrice = isB2BRetailPrices ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.GetDouble("Ecom:Product.DBPrice") * orderline.GetDouble("Ecom:Order:OrderLine.Quantity")) : orderline.GetString("Ecom:Order:OrderLine.TotalPrice"); 3968 var priceRaw = isB2BRetailPrices ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.GetDouble("Ecom:Product.DBPrice")) : orderline.GetString("Ecom:Order:OrderLine.UnitPrice"); 3969 if (isDiscountOrderline) 3970 { 3971 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight">&nbsp;</div> 3972 } 3973 else 3974 { 3975 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight"> 3976 @if (orderLineType == OrderLineType.PointProduct) 3977 { 3978 @:@orderline.GetString("Ecom:Order:OrderLine.UnitPoints")&nbsp;@Translate(orderline.GetString("Ecom:Order:OrderLine.UnitPoints") == "1" ? "point" : "points") 3979 } 3980 else if (isB2B && orderline.GetDouble("Ecom:Product.DBPrice") > 0 && !orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price").Equals(orderline.GetDouble("Ecom:Product.DBPrice")) && !isB2BRetailPrices) 3981 { 3982 <strong class="hidden-sm hidden-md hidden-lg pull-left">@headerUnitPrice</strong> 3983 <del>@Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.GetDouble("Ecom:Product.DBPrice"))</del><br/> 3984 <span>@orderline.GetString("Ecom:Order:OrderLine.UnitPrice")</span> 3985 } 3986 else 3987 { 3988 @priceRaw 3989 } 3990 </div> 3991 } 3992 3993 <div class="col-xs-6 col-xs-offset-4 col-sm-offset-0 col-sm-2 quantity noPaddingLeft mdAlignRight"> 3994 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 3995 { 3996 <strong class="hidden-sm hidden-md hidden-lg pull-left">@Translate("Qty")&nbsp;&nbsp;</strong> 3997 if (outputType != CartOutputType.Editable || orderLineType == OrderLineType.Discount || orderLineType == OrderLineType.ProductDiscount || orderLineType == OrderLineType.GiftCard || orderline.GetInteger("Ecom:Product.Type") == 1) 3998 { 3999 <span>@productQuantity</span> 4000 } 4001 else 4002 { 4003 <form class="cartChange" method="POST" action="@SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> 4004 @InternalRenderQuantityField(productStock, productAvailableAmount, productQuantity, orderline.GetString("Ecom:Order:OrderLine.Quantity.Input.Name"), 10, true, variantText.IsNotNullOrEmpty()) 4005 </form> 4006 } 4007 } 4008 </div> 4009 4010 <div class="col-xs-12 col-sm-2 totalPrice text-right noPadding-xs mdAlignRight @tempCssClass"> 4011 @totalPrice 4012 @if (outputType == CartOutputType.Editable && !isDiscountOrderline) 4013 { 4014 <a class="removeFromCart" href="@orderline.GetString("Ecom:Order:OrderLine.DeleteLink")"> 4015 @RenderIcon("fa-times") 4016 </a> 4017 } 4018 </div> 4019 } 4020 </li> 4021 } 4022 @helper InternalRenderCartContentLineCustom(Order order, OrderLine orderline, CartOutputType outputType) 4023 { 4024 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 4025 var productStock = 999999; 4026 var productAvailableAmount = 999999; 4027 var productQuantity = Converter.ToInt32(orderline.Quantity); 4028 var productId = orderline.ProductId; 4029 var variantId = orderline.ProductVariantId; 4030 var productName = orderline.ProductName; 4031 var productNumber = orderline.ProductNumber; 4032 var productImage = orderline.ProductId.IsNotNullOrEmpty() ? Dna.Hewitt.Images.GetHewittImagePath(orderline) : string.Empty; 4033 productImage = productImage.StartsWith("/Files", StringComparison.InvariantCultureIgnoreCase) ? productImage : string.Concat("/Files", productImage); 4034 var imageUrl = Images.GetImage(productImage, 95, 95); 4035 var variantText = orderline.ProductVariantText; 4036 var isDiscountOrderline = orderline.DiscountId.IsNotNullOrEmpty() || orderline.OrderLineType == OrderLineType.Discount || orderline.ParentLineId.IsNotNullOrEmpty(); 4037 var productUrl = isDiscountOrderline ? string.Empty : SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=" + Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "Products").ID + "&GroupID=" + (orderline.Product != null && orderline.Product.DefaultGroup != null ? orderline.Product.DefaultGroup.Id : string.Empty) + "&ProductID=" + productId + (variantId.IsNotNullOrEmpty() ? string.Concat("&VariantID=", variantId) : string.Empty)); 4038 var figureClass = outputType == CartOutputType.MiniCart ? "text-center col-xs-3 noPadding" : "text-center col-xs-4"; 4039 var prodContainerClass = outputType == CartOutputType.MiniCart ? "col-xs-9 noPaddingRight" : "col-xs-8 prodName noPadding"; 4040 prodContainerClass = string.Concat(prodContainerClass, isDiscountOrderline ? outputType == CartOutputType.MiniCart ? " col-xs-offset-3" : " col-xs-offset-4" : string.Empty); 4041 var productFriendlyUrl = string.Concat(Helpers.GetCurrentUrl(true), productUrl); 4042 var shareFacebookUrl = string.Concat("https://www.facebook.com/sharer/sharer.php?u=",productFriendlyUrl); 4043 var shareTwitterUrl = string.Concat("https://twitter.com/home?status=", productFriendlyUrl); 4044 var headerUnitPrice = isB2B ? Translate("Dealer price:") : Translate("Unit price"); 4045 var isPdfRequest = Sanitize.Parameter("pdf").IsNotNullOrEmpty(); 4046 var imageSettings = new ImageSettings 4047 { 4048 Source = imageUrl, 4049 AltText = productName, 4050 Href = productUrl, 4051 IncludeWrapper = true, 4052 WrapperElement = Sanitize.Parameter("print").IsNotNullOrEmpty() ? "div" : "figure", 4053 WrapperCssClass = figureClass 4054 }; 4055 var orderlineId = orderline.Id; 4056 var liClass = string.Concat("col-xs-12 col-sm-", outputType == CartOutputType.MiniCart ? "12" : "6" , " noPaddingLeft noPadding-xs"); 4057 var h2Class = outputType == CartOutputType.MiniCart && isDiscountOrderline && productId.IsNullOrEmpty() ? "col-xs-9 noPadding" : ""; 4058 <li class="col-xs-12 noPadding" data-facebook="@shareFacebookUrl" data-twitter="@shareTwitterUrl" data-isdiscount="@isDiscountOrderline"> 4059 <div class="@liClass"> 4060 @if (!isDiscountOrderline) 4061 { 4062 @RenderImage(imageSettings) 4063 } 4064 4065 <div class="@prodContainerClass"> 4066 <h2 class="@h2Class"> 4067 @if (isDiscountOrderline) 4068 { 4069 <strong>@productName</strong> 4070 } 4071 else 4072 { 4073 <a href="@productUrl"> 4074 <strong>@productName</strong> 4075 @if (variantText.IsNotNullOrEmpty()) 4076 { 4077 <br/> 4078 <small>@variantText</small> 4079 } 4080 </a> 4081 } 4082 </h2> 4083 @if (outputType == CartOutputType.MiniCart) 4084 { 4085 if (isDiscountOrderline && productId.IsNullOrEmpty()) 4086 { 4087 <span class="col-xs-3 noPadding text-right">@RenderProductPrice(orderline.Price.PriceFormatted)</span> 4088 } 4089 else 4090 { 4091 <span class="col-xs-12 noPadding"> 4092 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 4093 { 4094 <strong>@Translate("Qty"): </strong> 4095 @orderline.Quantity 4096 } 4097 <span class="pull-right">@RenderProductPrice(orderline.Price.PriceFormatted)</span> 4098 </span> 4099 } 4100 } 4101 else if (productNumber.IsNotNullOrEmpty() && outputType != CartOutputType.MiniCart) 4102 { 4103 <div class="itemDetails"> 4104 @Translate("Item number"): @productNumber 4105 </div> 4106 } 4107 @if (outputType != CartOutputType.MiniCart) 4108 { 4109 var noteField = orderline.get_OrderLineFieldValue("Note"); 4110 4111 if(noteField != null) 4112 { 4113 4114 var orderlinefield = noteField.OrderLineFieldSystemName; 4115 var orderlinefieldName = noteField.OrderLineFieldName; 4116 var orderlinefieldValue = noteField.Value; 4117 4118 <div class="orderlineNote"> 4119 @if (!orderlinefieldValue.IsNotNullOrEmpty() && !isPdfRequest) 4120 { 4121 <div> 4122 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Add Note")</a> 4123 </div> 4124 } 4125 else if (orderlinefieldValue.IsNotNullOrEmpty()) 4126 { 4127 <div> 4128 <strong>@orderlinefieldName:</strong> @orderlinefieldValue<br/> 4129 </div> 4130 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Edit Note")</a> 4131 } 4132 </div> 4133 if (outputType == CartOutputType.Editable) 4134 { 4135 <div style="display: none"> 4136 <div id="edit-note@(orderlineId)" style="width: 460px;"> 4137 <form class="cartChange" method="POST" action="@SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> 4138 <h2>@Translate("Product Note")</h2> 4139 @orderlinefieldName:<br/> 4140 @orderlinefield <br/> 4141 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"), "btn btn-bg"))<br/> 4142 </form> 4143 </div> 4144 </div> 4145 } 4146 } 4147 } 4148 </div> 4149 4150 </div> 4151 4152 @if (outputType != CartOutputType.MiniCart) 4153 { 4154 var orderLineType = orderline.OrderLineType; 4155 var tempCssClass = !isDiscountOrderline ? "noPadding" : string.Empty; 4156 if (isDiscountOrderline) 4157 { 4158 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight">&nbsp;</div> 4159 } 4160 else 4161 { 4162 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight"> 4163 @if (orderLineType == OrderLineType.PointProduct) 4164 { 4165 var orderlinePoints = orderline.UnitPoints ?? 0D; 4166 @:@orderlinePoints&nbsp;@Translate(orderlinePoints == 1 ? "point" : "points") 4167 } 4168 else if (isB2B && orderline.Product.DefaultPrice > 0 && !orderline.UnitPrice.Price.Equals(orderline.Product.DefaultPrice)) 4169 { 4170 <strong class="hidden-sm hidden-md hidden-lg pull-left">@headerUnitPrice</strong> 4171 <del>@Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.Product.DefaultPrice)</del><br/> 4172 <span>@orderline.UnitPrice.PriceFormatted</span> 4173 } 4174 else 4175 { 4176 @orderline.UnitPrice.PriceFormatted 4177 } 4178 </div> 4179 } 4180 4181 <div class="col-xs-6 col-xs-offset-4 col-sm-offset-0 col-sm-2 quantity noPaddingLeft mdAlignRight"> 4182 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 4183 { 4184 <strong class="hidden-sm hidden-md hidden-lg pull-left">@Translate("Qty")&nbsp;&nbsp;</strong> 4185 if (outputType != CartOutputType.Editable || orderLineType == OrderLineType.Discount || orderLineType == OrderLineType.ProductDiscount || orderLineType == OrderLineType.GiftCard || orderline.Product.Type == Dynamicweb.Ecommerce.Products.ProductType.Service) 4186 { 4187 <span>@productQuantity</span> 4188 } 4189 } 4190 </div> 4191 4192 <div class="col-xs-12 col-sm-2 totalPrice text-right noPadding-xs mdAlignRight @tempCssClass"> 4193 @orderline.Price.PriceFormatted 4194 </div> 4195 } 4196 </li> 4197 } 4198 @helper InternalRenderEmailCartContentLineCustom(LoopItem orderline) 4199 { 4200 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 4201 var domain = GetWebsiteDomain(Pageview); 4202 var productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 4203 var variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 4204 var productName = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 4205 var productNumber = orderline.GetString("Ecom:Product.Number"); 4206 var productImage = Dna.Hewitt.Images.GetHewittImagePath(orderline); 4207 productImage = productImage.IsNotNullOrEmpty() ? productImage : Pageview.Area.Item["NoImage"].ToString(); 4208 var imageUrl = domain + "/" + Images.GetImage(productImage, 95, 123) + "?Skip404=true"; 4209 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 4210 var isDiscountOrderline = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount") || orderline.GetString("Ecom:Order:OrderLine.ParentLineID").IsNotNullOrEmpty(); 4211 var productUrl = "Default.aspx?Id=" + Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "Products").ID + "&GroupID=" + orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID") + "&ProductID=" + productId + (variantId.IsNotNullOrEmpty() ? string.Concat("&VariantID=", variantId) : string.Empty); 4212 productUrl = domain + SearchEngineFriendlyURLs.GetFriendlyUrl(productUrl); 4213 var headerUnitPrice = Dna.Hewitt.Helpers.IsUserB2B() ? Translate("Dealer price") : Translate("Unit price"); 4214 4215 @RenderTableRowSpacer(isDiscountOrderline ? 5 : 10, 3) 4216 4217 <tr> 4218 <td> 4219 <figure align="left"> 4220 @if (isDiscountOrderline) 4221 { 4222 <text>&nbsp;</text> 4223 } 4224 else 4225 { 4226 <a target="_blank" href="@productUrl"> 4227 <img alt="@productName" title="@productName" src="@imageUrl" width="95"/> 4228 </a> 4229 } 4230 </figure> 4231 </td> 4232 <td valign="top"> 4233 @if (isDiscountOrderline) 4234 { 4235 <strong>@productName</strong> 4236 if (variantText.IsNotNullOrEmpty() || productNumber.IsNotNullOrEmpty()) 4237 { 4238 <br/> 4239 } 4240 if (variantText.IsNotNullOrEmpty()) 4241 { 4242 @variantText 4243 if (productNumber.IsNotNullOrEmpty()) 4244 { 4245 <text> - </text> 4246 } 4247 } 4248 if (productNumber.IsNotNullOrEmpty()) 4249 { 4250 <text>@Translate("Item number"): @productNumber</text> 4251 } 4252 } 4253 else 4254 { 4255 <a target="_blank" href="@productUrl"> 4256 <strong>@productName</strong> 4257 @if (variantText.IsNotNullOrEmpty() || productNumber.IsNotNullOrEmpty()) 4258 { 4259 <br/> 4260 } 4261 @if (variantText.IsNotNullOrEmpty()) 4262 { 4263 @variantText 4264 if (productNumber.IsNotNullOrEmpty()) 4265 { 4266 <text> - </text> 4267 } 4268 } 4269 @if (productNumber.IsNotNullOrEmpty()) 4270 { 4271 <text>@Translate("Item number"): @productNumber</text> 4272 } 4273 </a> 4274 } 4275 <br/> 4276 @if (!isDiscountOrderline) 4277 { 4278 if (orderLineType == OrderLineType.PointProduct) 4279 { 4280 @:<strong>@orderline.GetString("Ecom:Order:OrderLine.UnitPoints")&nbsp;@Translate(orderline.GetString("Ecom:Order:OrderLine.UnitPoints") == "1" ? "point" : "points")</strong> 4281 } 4282 else 4283 { 4284 <strong>@headerUnitPrice</strong> 4285 @orderline.GetString("Ecom:Order:OrderLine.UnitPrice") 4286 } 4287 4288 <br/> 4289 <strong>@Translate("Quantity")</strong> 4290 @orderline.GetString("Ecom:Order:OrderLine.Quantity") 4291 <br/> 4292 foreach (LoopItem item in orderline.GetLoop("Order.OrderLineFields")) 4293 { 4294 var orderlinefieldName = item.GetString("Ecom:Order:OrderLine.OrderLineField.Name"); 4295 var orderlinefieldValue = item.GetString("Ecom:Order:OrderLine.OrderLineField.Value"); 4296 <div class="orderlineNote"> 4297 @if (orderlinefieldValue.IsNotNullOrEmpty() && orderlinefieldName == "Note") 4298 { 4299 <div> 4300 <strong>@orderlinefieldName:</strong> @orderlinefieldValue<br/> 4301 </div> 4302 } 4303 </div> 4304 } 4305 } 4306 else if(productId.IsNotNullOrEmpty()) 4307 { 4308 <strong>@Translate("Quantity")</strong> 4309 @orderline.GetString("Ecom:Order:OrderLine.Quantity") 4310 } 4311 </td> 4312 <td class="noPadding" valign="top" style="text-align: right; padding-right: 90px"> 4313 <strong>@orderline.GetString("Ecom:Order:OrderLine.TotalPrice")</strong> 4314 </td> 4315 </tr> 4316 <tr> 4317 <td style="border-bottom: 1px solid @GetPalletColorNumber(1) text-align:left" colspan="3" height="10"></td> 4318 </tr> 4319 } 4320 @helper RenderOrderEmailButton(string href, string text, Dictionary<string, string> options = null) 4321 { 4322 if (href.IsNotNullOrEmpty() && text.IsNotNullOrEmpty()) 4323 { 4324 var width = options != null && options.ContainsKey("width") ? options["width"] : "120px"; 4325 var height = options != null && options.ContainsKey("height") ? options["height"] : "36px"; 4326 var background = options != null && options.ContainsKey("background") ? options["background"] : "#13315f"; 4327 var border = options != null && options.ContainsKey("border") ? options["border"] : "1px solid ffffff"; 4328 var color = options != null && options.ContainsKey("color") ? options["color"] : "#ffffff"; 4329 var fontFamily = options != null && options.ContainsKey("font-family") ? options["font-family"] : "Helvetica, Arial, sans-serif"; 4330 var fontSize = options != null && options.ContainsKey("font-size") ? options["font-size"] : "14px"; 4331 var fontStyle = options != null && options.ContainsKey("font-style") ? options["font-style"] : "normal"; 4332 var textAlign = options != null && options.ContainsKey("text-align") ? options["text-align"] : "center"; 4333 var textDecoration = options != null && options.ContainsKey("text-decoration") ? options["text-decoration"] : "none"; 4334 4335 var rect = "style=\"width:" + width + ";height:" + height + ";border:" + border + ";color:" + color + ";v-text-anchor:middle; \" fillcolor=\"" + background + "\""; 4336 var anchor = "width:" + width + ";height:" + height + ";line-height:" + height + ";background:" + background + ";border:" + border + ";color:" + color + ";font-family:" + fontFamily + ";font-size:" + fontSize + ";font-style:" + fontStyle + ";text-align:" + textAlign + ";text-decoration:" + textDecoration + ";"; 4337 4338 <div> 4339 <!--[if mso]> 4340 <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="@href" @rect> 4341 <w:anchorlock/> 4342 <center> 4343 <![endif]--> 4344 <a class="mobile-button" target="_blank" href="@href" style="-webkit-text-size-adjust: none; display: inline-block; @anchor">@text</a> 4345 <!--[if mso]> 4346 </center> 4347 </v:rect> 4348 <![endif]--> 4349 </div> 4350 } 4351 } 4352 @helper RenderCheckoutActionsCustom(bool showPrevious = false, bool isStep2Or3 = false, bool isB2B = false) 4353 { 4354 <div class="continueButton col-xs-12"> 4355 @if (showPrevious) 4356 { 4357 var previousButton = "/Default.aspx?Id=" + Pageview.Page.ID + "&amp;" + GetString("CartV2.PreviousStepButtonName") + "=true"; 4358 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Previous"), previousButton, "pull-left previousButton")) 4359 } 4360 @if (User.IsExtranetUserLoggedIn() && Pageview.User.CurrentSecondaryUser != null) { 4361 4362 var secondaryUser = User.GetUserByID(Pageview.User.CurrentSecondaryUser.ID); 4363 var t = secondaryUser.CustomFieldValues.First(x => x.CustomField.SystemName == "AccessUser_DisallowOrdering").Value; 4364 4365 if (t != null) 4366 { 4367 if (isStep2Or3 && t.ToString() == "True") 4368 { 4369 4370 } 4371 else 4372 { 4373 @RenderField(FieldSettings.CreateSubmitField(Translate(isB2B ? "Place order" : "Next"), "btn-default pull-right")) 4374 } 4375 } 4376 } 4377 else { 4378 @RenderField(FieldSettings.CreateSubmitField(Translate("Next"), "btn-default pull-right")) 4379 } 4380 4381 </div> 4382 } 4383 @helper RenderCartSummaryCustom(List<LoopItem> orderlines, bool splitAddresses = true, bool showEditOrder = true) 4384 { 4385 var orderDiscount = orderlines 4386 .Where(t => t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.Discount || t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.ProductDiscount && t.GetString("Ecom:Order:OrderLine.ParentLineID").IsNullOrEmpty()) 4387 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 4388 4389 var areAddessesTheSame = AreAddressesTheSame(); 4390 4391 var shippingSurcharge = GetDouble("ShippingFeeSurchargePortion.Clean"); 4392 var shippingMethodPrice = GetDouble("Ecom:Order.ShippingFee.Price"); 4393 var shippingMethodPriceFormatted = GetString("Ecom:Order.ShippingFee.PriceWithoutVATFormatted"); 4394 4395 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 4396 { 4397 shippingMethodPrice -= shippingSurcharge; 4398 shippingMethodPriceFormatted = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice); 4399 } 4400 4401 <h2 data-cartid="@GetString("Ecom:Order.ID")">@Translate("Order Summary")</h2> 4402 4403 if (orderlines.Any()) 4404 { 4405 var billingAndShippingAddressesTranslate = Translate("Billing & Shipping Address"); 4406 var billingAddressTranslate = Translate("Billing Address"); 4407 var shippingAddressTranslate = Translate("Shipping Address"); 4408 4409 <dl data-billingandshippingaddresses='@billingAndShippingAddressesTranslate' data-billingaddress='@billingAddressTranslate' data-shippingaddress='@shippingAddressTranslate'> 4410 @if(GetString("Ecom:Order.Customer.Name").IsNotNullOrEmpty()) { 4411 <dt class="col-xs-12 rightTitle borderBottom shippingAddressTitle"> 4412 @shippingAddressTranslate 4413 </dt> 4414 <dd class="col-xs-12 shippingAddress"> 4415 @if(GetString("Ecom:Order.Delivery.Name").IsNotNullOrEmpty()) 4416 { 4417 @GetString("Ecom:Order.Delivery.Name")<br/> 4418 } 4419 @GetAddressFormatted(AddressSource.EcomDelivery, false, true, true, "<br/>") 4420 </dd> 4421 if (splitAddresses) 4422 { 4423 <dt class="col-xs-12 rightTitle billingAddressTitle"> 4424 @billingAddressTranslate 4425 </dt> 4426 <dd class="col-xs-12 billingAddress"> 4427 @GetString("Ecom:Order.Customer.Name")<br/> 4428 @GetAddressFormatted(AddressSource.EcomCustomer, false, true, true, "<br/>") 4429 </dd> 4430 } 4431 } 4432 4433 @InternalRenderCartSummaryLine(Translate("Payment Method"), GetString("Ecom:Order.PaymentMethod"), string.Empty, "paymentMethodName", false, true) 4434 4435 <dt class="col-xs-12 borderBottom orderSummaryDeta">@Translate("Items")</dt> 4436 <dd class="col-xs-12 osProducts"> 4437 <ul> 4438 @foreach (var orderline in orderlines.Where(ol => ol.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Discount && ol.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Tax)) 4439 { 4440 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 4441 var isDiscountOrderline = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount") || orderline.GetString("Ecom:Order:OrderLine.ParentLineID").IsNotNullOrEmpty(); 4442 4443 <li class="col-xs-12 noPadding" data-isdiscount="@isDiscountOrderline"> 4444 <div class="col-xs-12 noPaddingLeft"> 4445 @orderline.GetString("Ecom:Order:OrderLine.ProductName") 4446 @if (variantText.IsNotNullOrEmpty()) 4447 { 4448 <br/> 4449 <small>@variantText</small> 4450 } 4451 </div> 4452 <div> 4453 <small class="col-xs-8 noPaddingLeft">@Translate("Qty"): @orderline.GetString("Ecom:Order:OrderLine.Quantity")</small> 4454 <span class="col-xs-4 text-right noPadding">@orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVATFormatted")</span> 4455 </div> 4456 </li> 4457 } 4458 </ul> 4459 </dd> 4460 4461 @if (GetDouble("Ecom:Order.TotalPoints") > 0) 4462 { 4463 @InternalRenderCartSummaryLine(Translate("Loyalty Points Spent"), GetString("Ecom:Order.TotalPoints"), "orderSummaryPointsSpent") 4464 } 4465 4466 @if (GetDouble("Ecom:Order.RewardTotalPoints") > 0) 4467 { 4468 @InternalRenderCartSummaryLine(Translate("Loyalty Points Earned"), GetString("Ecom:Order.RewardTotalPoints"), "orderSummaryPointsEarned") 4469 } 4470 4471 @InternalRenderCartSummaryLine(Translate("Subtotal"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderlines.Where(x => x.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Discount && x.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Tax).Sum(x => x.GetDouble("Ecom:Order:OrderLine.TotalPriceWithoutSymbol")), true), "orderSummarySubtotal", string.Empty, true) 4472 4473 @if (orderDiscount < 0) 4474 { 4475 @InternalRenderCartSummaryLine(Translate("Discount"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true), "orderSummaryOrderSavings") 4476 } 4477 4478 @InternalRenderCartSummaryLine(GetString("Ecom:Order.ShippingMethod").IsNotNullOrEmpty() ? GetString("Ecom:Order.ShippingMethod") : GetString("Ecom:Order.ShippingMethodID"), shippingMethodPrice > 0 ? shippingMethodPriceFormatted : "&nbsp;", "orderSummaryShippingName", "orderSummaryShippingPrice", false, true) 4479 4480 @InternalRenderCartSummaryLine(Translate("Taxes"), GetDouble("Ecom:Order.Taxes.Total.Price") > 0 ? GetString("Ecom:Order.Taxes.Total") : "", "orderSummaryTaxes", "orderSummaryTotalTaxes", false, true) 4481 @InternalRenderCartSummaryLine(Translate("Shipping Surcharge"), (shippingSurcharge > 0 ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingSurcharge) : ""), "orderSurcharge", "orderSurchargeTotal", false, true) 4482 @InternalRenderCartSummaryLine(Translate("Total"), GetString("Ecom:Order.OrderLines.Total.PriceWithoutVAT"), "orderSummaryTotalLabel", "orderSummaryTotal", true) 4483 </dl> 4484 4485 @InternalRenderOrderAmountsDisclaimerCustom(orderlines, Dna.Hewitt.Helpers.IsUserB2B()) 4486 4487 if (showEditOrder) 4488 { 4489 <div id="editOrderButton" class="col-xs-12 text-center"> 4490 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Edit order"), string.Concat(SearchEngineFriendlyURLs.GetFriendlyUrl(Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "MyCart").ID), "?CartV2.GotoStep0=true"), "btn-outline")) 4491 </div> 4492 } 4493 } 4494 } 4495 4496 @helper RenderCartContentsSummaryCustom(List<LoopItem> orderlines, string voucherValue, CartOutputType outputType = CartOutputType.ReadOnly) 4497 { 4498 @RenderCartContentsSummaryCustom(orderlines, voucherValue, PromoCodeChecker.CheckOrderPromoCode(voucherValue), outputType) 4499 } 4500 4501 @helper RenderCartContentsSummaryCustom(List<LoopItem> orderlines, string voucherValue, PromoCodeInfo voucherResult, CartOutputType outputType = CartOutputType.ReadOnly) 4502 { 4503 var orderDiscount = orderlines 4504 .Where(t => t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.Discount || t.GetInteger("Ecom:Order:OrderLine.Type") == (int) OrderLineType.ProductDiscount && t.GetString("Ecom:Order:OrderLine.ParentLineID").IsNullOrEmpty()) 4505 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 4506 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 4507 var myCartPage = Pageview.Page.ID == GetPageIdByNavigationTag("MyCart"); 4508 var isB2BRetailPrices = isB2B && (HttpContext.Current.Request.Cookies["isRetailPrice"]?.Value ?? "false").Equals("true") && myCartPage; 4509 4510 if (outputType != CartOutputType.Email && !isB2BRetailPrices) 4511 { 4512 @:<div id="totalPriceContainer" class="col-xs-12 col-sm-5 noPadding pull-right noPadding-xs"> 4513 } 4514 4515 if (voucherResult.Valid && !voucherResult.Expired && !voucherResult.Inactive && voucherValue.IsNotNullOrEmpty()) 4516 { 4517 <div class="col-xs-12 noPadding"> 4518 <div class="discountContainer col-xs-12"> 4519 <div class="row"> 4520 <span class="col-xs-8 col-sm-7 noPadding">@Translate("Voucher"): @EcommerceHelpers.GetVoucherName(voucherValue)</span> 4521 </div> 4522 </div> 4523 </div> 4524 } 4525 4526 if (GetDouble("Ecom:Order.TotalPoints") > 0) 4527 { 4528 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Spent"), GetString("Ecom:Order.TotalPoints"), false, outputType) 4529 } 4530 4531 if (GetDouble("Ecom:Order.RewardTotalPoints") > 0) 4532 { 4533 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Earned"), GetString("Ecom:Order.RewardTotalPoints"), false, outputType) 4534 } 4535 if (GetString("Ecom:Order.PriceWithoutFees.PriceFormatted") != "0.00") 4536 { 4537 @InternalRenderTotalAmountLineCustom(Translate("Subtotal"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderlines.Where(x => x.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Discount && x.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Tax).Sum(x => x.GetDouble("Ecom:Order:OrderLine.TotalPriceWithoutSymbol")), true), true, outputType, "fontSize16") 4538 } 4539 4540 if (orderDiscount < 0) 4541 { 4542 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 4543 var discount = orderDiscount < 0 ? Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true) : GetString("Ecom:Order.TotalDiscount"); 4544 @InternalRenderTotalAmountLineDiscount(voucherCode.IsNotNullOrEmpty() ? string.Concat(Translate("Coupon Code"), ": ", voucherCode) : Translate("Order Discounts"), discount, false, outputType) 4545 } 4546 if (GetString("Ecom:Order.ShippingMethodID").IsNotNullOrEmpty() || GetString("Ecom:Order.ShippingMethod").IsNotNullOrEmpty()) 4547 { 4548 var shippingSurcharge = GetDouble("ShippingFeeSurchargePortion.Clean"); 4549 var shippingMethodPrice = GetDouble("Ecom:Order.ShippingFee.Price"); 4550 var shippingMethodPriceFormatted = GetString("Ecom:Order.ShippingFee.PriceWithoutVATFormatted"); 4551 4552 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 4553 { 4554 shippingMethodPrice -= shippingSurcharge; 4555 shippingMethodPriceFormatted = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice); 4556 } 4557 4558 @InternalRenderTotalAmountLineCustom(GetString("Ecom:Order.ShippingMethod").IsNotNullOrEmpty() ? GetString("Ecom:Order.ShippingMethod") : GetString("Ecom:Order.ShippingMethodID"), shippingMethodPrice > 0 ? shippingMethodPriceFormatted : "&nbsp;", false, outputType) 4559 4560 if (shippingSurcharge > 0) 4561 { 4562 @InternalRenderTotalAmountLineCustom(Translate("Shipping Surcharge"), Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingSurcharge), false, outputType) 4563 } 4564 } 4565 if (GetString("Ecom:Order.Taxes.Total.Price") != "0.00") 4566 { 4567 @InternalRenderTotalAmountLineCustom(Translate("Taxes"), GetString("Ecom:Order.Taxes.Total"), false, outputType) 4568 } 4569 @InternalRenderTotalAmountLineCustom(string.Concat(GetString("Ecom:Order.Completed").IsNullOrEmpty() ? "*" : string.Empty, Translate("Total")), GetString("Ecom:Order.Price"), true, outputType) 4570 4571 if (outputType != CartOutputType.Email) 4572 { 4573 if(GetString("Ecom:Order.Completed").IsNullOrEmpty()) 4574 { 4575 @InternalRenderOrderAmountsDisclaimerCustom(orderlines, Dna.Hewitt.Helpers.IsUserB2B()) 4576 } 4577 @: </div> 4578 } 4579 } 4580 4581 @helper RenderCartContentsSummaryCustom(Order order, OrderLineCollection orderlines, string voucherValue, CartOutputType outputType = CartOutputType.ReadOnly) 4582 { 4583 @RenderCartContentsSummaryCustom(order, orderlines, voucherValue, PromoCodeChecker.CheckOrderPromoCode(voucherValue), outputType) 4584 } 4585 4586 @helper RenderCartContentsSummaryCustom(Order order, OrderLineCollection orderlines, string voucherValue, PromoCodeInfo voucherResult, CartOutputType outputType = CartOutputType.ReadOnly) 4587 { 4588 var orderDiscount = orderlines.Where(t => t.OrderLineType == OrderLineType.Discount || t.OrderLineType == OrderLineType.ProductDiscount && t.ParentLineId.IsNullOrEmpty()).Sum(s => s.Price.Price); 4589 var subtotal = orderlines.Where(x => x.OrderLineType != OrderLineType.Discount && x.OrderLineType != OrderLineType.Tax).Sum(x => x.Price.Price); 4590 var taxesTotal = orderlines.Where(x => x.OrderLineType == OrderLineType.Tax).Sum(x => x.Price.Price); 4591 4592 if (outputType != CartOutputType.Email) 4593 { 4594 @:<div id="totalPriceContainer" class="col-xs-12 col-sm-5 noPadding pull-right noPadding-xs"> 4595 } 4596 4597 if (voucherResult.Valid && !voucherResult.Expired && !voucherResult.Inactive && voucherValue.IsNotNullOrEmpty()) 4598 { 4599 <div class="col-xs-12 noPadding"> 4600 <div class="discountContainer col-xs-12"> 4601 <div class="row"> 4602 <span class="col-xs-8 col-sm-7 noPadding">@Translate("Voucher"): @EcommerceHelpers.GetVoucherName(voucherValue)</span> 4603 </div> 4604 </div> 4605 </div> 4606 } 4607 4608 if ((order.TotalPoints ?? 0) > 0) 4609 { 4610 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Spent"), order.TotalPoints.ToString(), false, outputType) 4611 } 4612 4613 if ((order.RewardTotalPoints ?? 0) > 0) 4614 { 4615 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Earned"), order.RewardTotalPoints.ToString(), false, outputType) 4616 } 4617 if (subtotal > 0) 4618 { 4619 @InternalRenderTotalAmountLineCustom(Translate("Subtotal"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, subtotal, true), true, outputType, "fontSize16") 4620 } 4621 4622 if (orderDiscount < 0) 4623 { 4624 var discount = orderDiscount < 0 ? Services.Currencies.Format(order.Currency, orderDiscount, true) : order.TotalDiscount.PriceFormatted; 4625 @InternalRenderTotalAmountLineDiscount(voucherValue.IsNotNullOrEmpty() ? string.Concat(Translate("Coupon Code"), ": ", voucherValue) : Translate("Order Discounts"), discount, false, outputType) 4626 } 4627 if (order.ShippingMethodId.IsNotNullOrEmpty() || order.ShippingMethod.IsNotNullOrEmpty()) 4628 { 4629 var shippingSurcharge = Converter.ToDouble(order.OrderFieldValues.FirstOrDefault(ofv => ofv.OrderField.SystemName.Equals("ShippingFeeSurchargePortion"))?.Value ?? 0); 4630 var shippingMethodPrice = order.ShippingFee.Price; 4631 var shippingMethodPriceFormatted = order.ShippingFee.PriceWithoutVATFormatted; 4632 4633 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 4634 { 4635 shippingMethodPrice -= shippingSurcharge; 4636 shippingMethodPriceFormatted = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice); 4637 } 4638 4639 @InternalRenderTotalAmountLineCustom(order.ShippingMethod.IsNotNullOrEmpty() ? order.ShippingMethod : order.ShippingMethodId, shippingMethodPrice > 0 ? shippingMethodPriceFormatted : "&nbsp;", false, outputType) 4640 4641 if (shippingSurcharge > 0) 4642 { 4643 @InternalRenderTotalAmountLineCustom(Translate("Shipping Surcharge"), Services.Currencies.Format(order.Currency, shippingSurcharge), false, outputType) 4644 } 4645 } 4646 if (taxesTotal > 0) 4647 { 4648 @InternalRenderTotalAmountLineCustom(Translate("Taxes"), Services.Currencies.Format(order.Currency, taxesTotal), false, outputType) 4649 } 4650 @InternalRenderTotalAmountLineCustom(string.Concat(order.CompletedDate?.ToString().IsNullOrEmpty() ?? true ? "*" : string.Empty, Translate("Total")), order.Price.PriceFormatted, true, outputType) 4651 } 4652 4653 @helper InternalRenderTotalAmountLineDiscount(string label, string value, bool isBold = false, CartOutputType outputType = CartOutputType.ReadOnly) 4654 { 4655 var orderIsNotCompleted = GetString("Ecom:Order.Completed").IsNullOrEmpty(); 4656 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 4657 var valueCssClass = orderIsNotCompleted && voucherCode.IsNullOrEmpty() ? "col-xs-12" : string.Empty; 4658 if (outputType == CartOutputType.Email) 4659 { 4660 <tr align="left"> 4661 <td> 4662 @InternalRenderValue(label, isBold) 4663 </td> 4664 <td> 4665 &nbsp; 4666 </td> 4667 <td class="noPadding" style="padding-right: 90px; text-align: right;"> 4668 @InternalRenderValue(value, isBold) 4669 </td> 4670 </tr> 4671 } 4672 else 4673 { 4674 var tempCssClass = orderIsNotCompleted ? "noPaddingRight" : string.Empty; 4675 <div class="col-xs-6 col-sm-7 clearLeft"> 4676 @InternalRenderValue(label, isBold) 4677 </div> 4678 <div class="col-xs-6 col-sm-5 price pull-right noPadding-xs text-right @tempCssClass"> 4679 <span class="totalsDiscountVal @valueCssClass"> 4680 @InternalRenderValue(value, isBold) 4681 </span> 4682 @if (orderIsNotCompleted && voucherCode.IsNotNullOrEmpty()) 4683 { 4684 <a class="removeVoucher" href="javascript:void(0)"> 4685 @RenderIcon("fa-times") 4686 </a> 4687 } 4688 </div> 4689 } 4690 } 4691 4692 @helper InternalRenderTotalAmountLineDiscount(Order order, string label, string value, bool isBold = false, CartOutputType outputType = CartOutputType.ReadOnly) 4693 { 4694 var orderIsNotCompleted = order.CompletedDate?.ToString().IsNullOrEmpty() ?? true; 4695 var voucherCode = order.VoucherCode; 4696 var valueCssClass = orderIsNotCompleted && voucherCode.IsNullOrEmpty() ? "col-xs-12" : string.Empty; 4697 if (outputType == CartOutputType.Email) 4698 { 4699 <tr align="left"> 4700 <td> 4701 @InternalRenderValue(label, isBold) 4702 </td> 4703 <td> 4704 &nbsp; 4705 </td> 4706 <td class="noPadding" style="padding-right: 90px; text-align: right;"> 4707 @InternalRenderValue(value, isBold) 4708 </td> 4709 </tr> 4710 } 4711 else 4712 { 4713 var tempCssClass = orderIsNotCompleted ? "noPaddingRight" : string.Empty; 4714 <div class="col-xs-6 col-sm-7 clearLeft"> 4715 @InternalRenderValue(label, isBold) 4716 </div> 4717 <div class="col-xs-6 col-sm-5 price pull-right noPadding-xs text-right @tempCssClass"> 4718 <span class="totalsDiscountVal @valueCssClass"> 4719 @InternalRenderValue(value, isBold) 4720 </span> 4721 @if (orderIsNotCompleted && voucherCode.IsNotNullOrEmpty()) 4722 { 4723 <a class="removeVoucher" href="javascript:void(0)"> 4724 @RenderIcon("fa-times") 4725 </a> 4726 } 4727 </div> 4728 } 4729 } 4730 4731 @helper RenderVoucherFieldCustom() 4732 { 4733 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 4734 var voucherCodeErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderVoucherCode.ErrorMessage"); 4735 var voucherResult = PromoCodeChecker.CheckOrderPromoCode(voucherCode); 4736 var validVoucherCss = voucherResult.Valid ? "hidden" : ""; 4737 var myCart = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("MyCart")); 4738 var isCheckoutFlow = Pageview.Page.ID == GetPageIdByNavigationTag("Checkout"); 4739 var submitVoucherBtn = new BootstrapButtonSettings 4740 { 4741 Label = Translate("Apply"), 4742 Id = "applyVoucher", 4743 CssClass = "btn-default submitVoucher", 4744 Href = "javascript:void(0)" 4745 }; 4746 4747 <h2 class="@validVoucherCss">@Translate("Coupon Code")</h2> 4748 <div id="promoCodeContainer" class="DMForms col-xs-12 noPadding stepContainer" data-error="@voucherCodeErrorMessage"> 4749 @if (!voucherResult.Valid || voucherResult.Expired || voucherResult.Inactive) 4750 { 4751 if (!isCheckoutFlow) 4752 { 4753 <form action="@myCart" method="post"> 4754 @RenderField(new FieldSettings {Type = FieldType.Text, Label = Translate("Enter a Voucher Code"), SystemName = "EcomOrderVoucherCode", Value = GetString("Ecom:Order.Customer.VoucherCode"), IncludeWrapper = false}) 4755 @RenderField(new FieldSettings 4756 { 4757 Type = FieldType.Submit, 4758 SystemName = "applyVoucher", 4759 Value = Translate("Apply"), 4760 CssClass = "btn-default submitVoucher" 4761 }) 4762 </form> 4763 } 4764 else 4765 { 4766 <fieldset> 4767 @RenderField(new FieldSettings {Type = FieldType.Text, Label = Translate("Enter a Voucher Code"), SystemName = "EcomOrderVoucherCode", Value = GetString("Ecom:Order.Customer.VoucherCode"), IncludeWrapper = false}) 4768 @RenderBootstrapButton(submitVoucherBtn) 4769 </fieldset> 4770 } 4771 } 4772 </div> 4773 } 4774 4775 @helper InternalRenderTotalAmountLineCustom(string label, string value, bool isBold = false, CartOutputType outputType = CartOutputType.ReadOnly, string cssClass = "") 4776 { 4777 if (outputType == CartOutputType.Email) 4778 { 4779 <tr align="left"> 4780 <td> 4781 @InternalRenderValue(label, isBold) 4782 </td> 4783 <td> 4784 &nbsp; 4785 </td> 4786 <td class="noPadding" style="padding-right: 90px; text-align: right;"> 4787 @InternalRenderValue(value, isBold) 4788 </td> 4789 </tr> 4790 } 4791 else 4792 { 4793 <div class="col-xs-6 col-sm-7 clearLeft @cssClass"> 4794 @InternalRenderValue(label, isBold) 4795 </div> 4796 <div class="col-xs-6 col-sm-5 price pull-right noPadding-xs text-right @cssClass"> 4797 @InternalRenderValue(value, isBold) 4798 </div> 4799 } 4800 } 4801 4802 @helper InternalRenderOrderAmountsDisclaimerCustom(List<LoopItem> orderlines, bool isB2B = false) 4803 { 4804 var orderCannotBeShipped = orderlines.Any(ol => !ol.GetBoolean("Ecom:Product:Field.CanShipWithStandardCarrier")); 4805 @* Taxes and Shipping disclaimer *@ 4806 if (GetString("Ecom:Order.Taxes.Total.Price") == "0.00" || GetBoolean("Ecom:Order.ShippingFee.IsZero")) 4807 { 4808 <small class="col-xs-12 noPadding"> 4809 @if (GetBoolean("Ecom:Order.ShippingFee.IsZero") && GetString("Ecom:Order.Taxes.Total.Price") == "0.00") 4810 { 4811 @Translate(isB2B && orderCannotBeShipped ? "* Taxes and Shipping calculated at time of shipping" : "* Taxes and Shipping calculated at Checkout") 4812 } 4813 else 4814 { 4815 @Translate(isB2B && orderCannotBeShipped ? "*Taxes Calculated at time of shipping" : "*Taxes Calculated at Checkout") 4816 } 4817 </small> 4818 } 4819 } 4820 } 4821 @functions 4822 { 4823 public void UpdateUserEmailPermission(string email, string shopId) 4824 { 4825 var page = Dynamicweb.Extensibility.ServiceLocator.Current.GetPageService().GetPage(GetPageIdByNavigationTag("GeneralSettings")); 4826 var generalSettings = Dynamicweb.Content.Items.Item.GetItemById(page.ItemType, page.ItemId); 4827 var newsletterGroups = generalSettings["NewsletterConsentGroups"].ToString().Split(',').Select(s => Convert.ToInt32(s)).ToList(); 4828 4829 if (User.IsExtranetUserLoggedIn()) 4830 { 4831 var currentUser = User.GetCurrentUser(); 4832 if (currentUser.EmailAllowed != true) 4833 { 4834 currentUser.EmailAllowed = true; 4835 foreach (var groupId in newsletterGroups) 4836 { 4837 currentUser.AddToGroup(groupId); 4838 } 4839 currentUser.Save(); 4840 } 4841 } 4842 else if(Dynamicweb.Data.Database.ExecuteNonQuery("UPDATE AccessUser SET ACCESSUSERNEWSLETTERALLOWED=1, ACCESSUSEREMAILPERMISSIONUPDATEDON=GETDATE(), ACCESSUSEREMAILPERMISSIONGIVENON=GETDATE(), ACCESSUSERGROUPS=CONCAT(ISNULL(ACCESSUSERGROUPS, ''), '@', '" + string.Join("@@", newsletterGroups) + "', '@') WHERE ISNULL(ACCESSUSEREMAIL,'')='" + email + "' AND ISNULL(ACCESSUSERSHOPID,'')='" + shopId + "'") == 0) 4843 { 4844 var newsletterUser = new User(); 4845 newsletterUser.EmailAllowed = true; 4846 newsletterUser.UserName = "newsletter-" + email; 4847 newsletterUser.Email = email; 4848 newsletterUser.ShopID = shopId; 4849 foreach (var groupId in newsletterGroups) 4850 { 4851 newsletterUser.AddToGroup(groupId); 4852 } 4853 newsletterUser.Save(); 4854 } 4855 } 4856 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 4857 @using System 4858 @using System.Collections.Generic 4859 @using System.Globalization 4860 @using Dna.Frontend 4861 @using Dna.Frontend.Forms 4862 @using Dynamicweb.Rendering 4863 @using Dynamicweb.Frontend 4864 @using System.Linq 4865 @using System.Web 4866 @using Dna.Frontend.UI 4867 @using Dna.Validation 4868 @using Dynamicweb.Core 4869 @using Dynamicweb.Ecommerce 4870 @using Dynamicweb.Ecommerce.Orders 4871 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 4872 @using Dynamicweb.Ecommerce.Products 4873 @using Dynamicweb.Content.Items 4874 @using FieldType = Dynamicweb.Forms.FieldType 4875 @using FieldOption = Dna.Frontend.Forms.FieldOption 4876 @{ InitEditOrders();} 4877 @functions{ 4878 readonly string parameterAddProduct = "AddProduct"; 4879 readonly string parameterProductId = "ProductId"; 4880 readonly string parameterVariantId = "VariantId"; 4881 readonly string parameterQuantity = "Quantity"; 4882 readonly string parameterUpdateQuantity = "UpdateQuantity"; 4883 readonly string parameterDeleteOrderline = "DeleteOrderline"; 4884 readonly string parameterUpdateNote = "UpdateNote"; 4885 readonly string parameterOrderLineId = "OrderlineID"; 4886 readonly string parameterFinishSave= "FinishSave"; 4887 readonly string parameterCancel = "Cancel"; 4888 readonly string shippingInstructionsOrderFieldSystemName = "ShippingInstructions"; 4889 readonly string instanceIdentifierOrderlineFieldSystemName = "InstanceIdentifier"; 4890 readonly string noteOrderlineFieldSystemName = "Note"; 4891 readonly string isEditingOrderFieldSystemName = "IsEditing"; 4892 readonly string forceIntegrationOrderFieldSystemName = "ForceIntegration"; 4893 readonly string editedByOrderFieldSystemName = "EditedBy"; 4894 readonly string shippingFeeSurchargePortionOrderFieldSystemName = "ShippingFeeSurchargePortion"; 4895 string currentPageUrl = string.Empty; 4896 string errorMessage = string.Empty; 4897 OrderService orderService; 4898 OrderLineService orderlineService; 4899 4900 public void InitEditOrders() 4901 { 4902 orderService = new OrderService(); 4903 orderlineService = new OrderLineService(); 4904 } 4905 4906 public string GetOrderCustomFieldValue(Order order, string fieldSystemName) 4907 { 4908 var orderCustomField = order.OrderFieldValues.FirstOrDefault(of => of.OrderField.SystemName.Equals(fieldSystemName)); 4909 4910 if (orderCustomField == null) 4911 { 4912 return string.Empty; 4913 } 4914 4915 return orderCustomField.Value.ToString(); 4916 } 4917 4918 public void SetOrderCustomFieldValue(Order order, string fieldSystemName, object value) 4919 { 4920 var orderCustomField = order.OrderFieldValues.FirstOrDefault(of => of.OrderField.SystemName.Equals(fieldSystemName)); 4921 4922 if (orderCustomField != null) 4923 { 4924 orderCustomField.Value = value; 4925 } 4926 } 4927 4928 public bool EditOrder(Order order) 4929 { 4930 var orderModified = false; 4931 var productService = new ProductService(); 4932 var parameterOrderLineIdValue = Sanitize.Parameter(parameterOrderLineId); 4933 4934 if (Sanitize.Parameter(parameterAddProduct, ParameterType.Number).IsNotNullOrEmpty()) 4935 { 4936 var product = productService.GetProductById(Sanitize.Parameter(parameterProductId), Sanitize.Parameter(parameterVariantId), Pageview.Area.EcomLanguageId); 4937 if (product != null) 4938 { 4939 PrepareOrderToUpdate(order); 4940 var sameOrderLineAddedBefore = order.OrderLines.FirstOrDefault(ol => ol.ProductId.Equals(product.Id) 4941 && ol.ProductVariantId.Equals(product.VariantId) 4942 && (ol.get_OrderLineFieldValue(noteOrderlineFieldSystemName)?.Value.Equals(string.Empty) ?? false) 4943 && (ol.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName)?.Value.Equals(HttpContext.Current.Session.SessionID) ?? false)); 4944 4945 if (sameOrderLineAddedBefore != null) 4946 { 4947 UpdateOrderLineQuantity(order, sameOrderLineAddedBefore,(sameOrderLineAddedBefore.Quantity + Convert.ToDouble(Sanitize.Parameter(parameterQuantity, ParameterType.Number)))); 4948 SaveOrderChanges(order); 4949 orderModified = true; 4950 } 4951 else 4952 { 4953 var orderLine = new OrderLine(); 4954 orderLine.Order = order; 4955 orderlineService.SetProductInformation(orderLine, product); 4956 orderlineService.SetUnitPrice(orderLine, product.GetPrice(order.CurrencyCode, order.CustomerCountryCode)); 4957 if (orderLine.UnitPrice.Price == 0) 4958 { 4959 orderlineService.Delete(orderLine.Id); 4960 SaveOrderChanges(order); 4961 } 4962 else 4963 { 4964 orderLine.Quantity = Convert.ToDouble(Sanitize.Parameter(parameterQuantity, ParameterType.Number)); 4965 orderLine.OrderLineFieldValues.Add(new OrderLineFieldValue(noteOrderlineFieldSystemName, string.Empty)); 4966 orderLine.OrderLineFieldValues.Add(new OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName, System.Web.HttpContext.Current.Session.SessionID)); 4967 orderLine.OrderLineType = OrderLineType.Product; 4968 order.OrderLines.Add(orderLine, true); 4969 orderlineService.Save(orderLine); 4970 orderService.ForcePriceRecalculation(order); 4971 SaveOrderChanges(order); 4972 orderModified = true; 4973 } 4974 } 4975 4976 } 4977 } 4978 else if (parameterOrderLineIdValue.IsNotNullOrEmpty()) 4979 { 4980 var orderLine = order.OrderLines.FirstOrDefault(ol => ol.Id.Equals(parameterOrderLineIdValue)); 4981 if (orderLine != null) 4982 { 4983 if (Sanitize.Parameter(parameterUpdateQuantity, ParameterType.Number).IsNotNullOrEmpty()) 4984 { 4985 PrepareOrderToUpdate(order); 4986 UpdateOrderLineQuantity(order, orderLine, Convert.ToDouble(Sanitize.Parameter(parameterQuantity, ParameterType.Number))); 4987 SaveOrderChanges(order); 4988 orderModified = true; 4989 } 4990 else if(Sanitize.Parameter(parameterUpdateNote, ParameterType.LongText) != null) 4991 { 4992 var noteField = orderLine.get_OrderLineFieldValue(noteOrderlineFieldSystemName); 4993 if (noteField != null) 4994 { 4995 noteField.Value = Sanitize.Parameter(parameterUpdateNote, ParameterType.LongText); 4996 } 4997 else 4998 { 4999 orderLine.OrderLineFieldValues.Add(new OrderLineFieldValue(noteOrderlineFieldSystemName, Sanitize.Parameter(parameterUpdateNote, ParameterType.LongText))); 5000 } 5001 5002 orderlineService.Save(orderLine); 5003 5004 var duplicatedOrderLine = order.OrderLines.FirstOrDefault(ol => orderlineService.CanBeMerged(ol,orderLine) && !ol.Id.Equals(orderLine.Id)); 5005 if (duplicatedOrderLine != null) 5006 { 5007 PrepareOrderToUpdate(order); 5008 UpdateOrderLineQuantity(order, duplicatedOrderLine, duplicatedOrderLine.Quantity + orderLine.Quantity); 5009 DeleteOrderLine(order, orderLine); 5010 SaveOrderChanges(order); 5011 } 5012 5013 orderModified = true; 5014 } 5015 else if (Sanitize.Parameter(parameterDeleteOrderline, ParameterType.Number).IsNotNullOrEmpty()) 5016 { 5017 PrepareOrderToUpdate(order); 5018 DeleteOrderLine(order, orderLine); 5019 SaveOrderChanges(order); 5020 orderModified = true; 5021 } 5022 } 5023 } 5024 else if (Sanitize.Parameter(shippingInstructionsOrderFieldSystemName, ParameterType.LongText).IsNotNullOrEmpty()) 5025 { 5026 PrepareOrderToUpdate(order); 5027 SetOrderCustomFieldValue(order, isEditingOrderFieldSystemName, true); 5028 SaveOrderChanges(order); 5029 HttpContext.Current.Response.Cookies.Add(new HttpCookie(string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName), Sanitize.Parameter(shippingInstructionsOrderFieldSystemName, ParameterType.LongText))); 5030 orderModified = true; 5031 } 5032 5033 if (orderModified) 5034 { 5035 orderService.RemoveOrderCache(order.Id); 5036 } 5037 5038 return orderModified; 5039 } 5040 5041 private void UpdateOrderLineQuantity(Order order, OrderLine orderLine, double qty = 0) 5042 { 5043 orderLine.Quantity = qty; 5044 orderlineService.Save(orderLine); 5045 orderService.ForcePriceRecalculation(order); 5046 } 5047 5048 private void DeleteOrderLine(Order order, OrderLine orderLine) 5049 { 5050 order.OrderLines.RemoveLine(orderLine.Id); 5051 orderlineService.Delete(orderLine.Id); 5052 orderService.ForcePriceRecalculation(order); 5053 } 5054 5055 private void PrepareOrderToUpdate(Order order) 5056 { 5057 order.IsCart = true; 5058 order.Complete = false; 5059 } 5060 5061 private void SaveOrderChanges(Order order, bool isEditing = true) 5062 { 5063 UpdateOrderShippingMethod(order); 5064 SetOrderCustomFieldValue(order, isEditingOrderFieldSystemName, isEditing); 5065 SetOrderCustomFieldValue(order, forceIntegrationOrderFieldSystemName, !isEditing); 5066 orderService.ForcePriceRecalculation(order); 5067 order.IsCart = false; 5068 order.Complete = true; 5069 orderService.Save(order); 5070 } 5071 5072 private void UpdateOrderShippingMethod(Order order) 5073 { 5074 var orderLimit = Convert.ToDouble(Pageview.Area.Item["Order_Limit"]); 5075 var shippingSurcharge = Convert.ToDouble(Pageview.Area.Item["Shipping_Surcharge"]); 5076 var subtotal = order.OrderLines.Where(ol => ol.OrderLineType != OrderLineType.Discount && ol.OrderLineType != OrderLineType.Tax).Sum(olp => olp.Price.Price); 5077 5078 if (order.ShippingMethodId.IsNullOrEmpty() || orderLimit == 0) 5079 { 5080 return; 5081 } 5082 5083 var shippingMethodsRelations = GetShippingMethodsRelations(); 5084 5085 if (shippingMethodsRelations.ContainsKey(order.ShippingMethodId) && shippingMethodsRelations.ContainsValue(order.ShippingMethodId)) 5086 { 5087 return; 5088 } 5089 5090 // Order value increased 5091 if (shippingMethodsRelations.ContainsKey(order.ShippingMethodId) && subtotal > orderLimit) 5092 { 5093 UpdateOrderShippingMethod(order, shippingMethodsRelations[order.ShippingMethodId], 0); 5094 } 5095 // Order value decreased (when user cancels the changes) 5096 else if (shippingMethodsRelations.ContainsValue(order.ShippingMethodId) && subtotal < orderLimit) 5097 { 5098 UpdateOrderShippingMethod(order, shippingMethodsRelations.First(x => x.Value.Equals(order.ShippingMethodId)).Key, shippingSurcharge); 5099 } 5100 } 5101 5102 private void UpdateOrderShippingMethod(Order order, string shippingMethodId, double shippingSurcharge) 5103 { 5104 var shippingMethod = Shipping.GetShippingmethodById(shippingMethodId); 5105 if (shippingMethod == null) 5106 { 5107 return; 5108 } 5109 order.ShippingMethodId = shippingMethod.Id; 5110 order.ShippingMethod = shippingMethod.Name; 5111 order.ShippingMethodDescription = shippingMethod.Description; 5112 SetOrderCustomFieldValue(order, shippingFeeSurchargePortionOrderFieldSystemName, shippingSurcharge); 5113 orderService.ForcePriceRecalculation(order); 5114 } 5115 5116 private bool FinishAndSaveOrder(Order order) 5117 { 5118 foreach (var orderLine in order.OrderLines) 5119 { 5120 var instanceIdentifierOrderlineField = orderLine.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName); 5121 if (instanceIdentifierOrderlineField != null && orderLine.OrderLineType == OrderLineType.Product) 5122 { 5123 instanceIdentifierOrderlineField.Value = string.Empty; 5124 orderlineService.Save(orderLine); 5125 } 5126 } 5127 5128 if (HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)] != null) 5129 { 5130 SetOrderCustomFieldValue(order, shippingInstructionsOrderFieldSystemName, HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)].Value); 5131 HttpContext.Current.Response.Cookies.Add(new HttpCookie(string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)){ Expires = DateTime.Now.AddDays(-1d) }); 5132 } 5133 5134 SetOrderCustomFieldValue(order, isEditingOrderFieldSystemName, false); 5135 SetOrderCustomFieldValue(order, forceIntegrationOrderFieldSystemName, false); 5136 SetOrderCustomFieldValue(order, editedByOrderFieldSystemName, GetAuditUserName()); 5137 order.StateId = "OS15"; 5138 orderService.Save(order); 5139 5140 // Try to update order on the fly, if it fails it will be sent by on batch job 5141 var orderUpdatedInErp = Dna.Ecommerce.LiveIntegration.TemplatesHelper.UpdateOrder(order); 5142 if (!orderUpdatedInErp.HasValue || (orderUpdatedInErp.HasValue && !orderUpdatedInErp.Value)) 5143 { 5144 SetOrderCustomFieldValue(order, forceIntegrationOrderFieldSystemName, true); 5145 orderService.Save(order); 5146 } 5147 5148 return true; 5149 } 5150 5151 private bool CancelOrder(Order order) 5152 { 5153 var orderlinesToRemove = new List<string>(); 5154 5155 foreach (var orderLine in order.OrderLines) 5156 { 5157 var instanceIdentifierOrderlineField = orderLine.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName); 5158 if (instanceIdentifierOrderlineField != null && orderLine.OrderLineType == OrderLineType.Product && instanceIdentifierOrderlineField.Value.Equals(System.Web.HttpContext.Current.Session.SessionID)) 5159 { 5160 orderlinesToRemove.Add(orderLine.Id); 5161 } 5162 } 5163 5164 PrepareOrderToUpdate(order); 5165 5166 if (orderlinesToRemove.Any()) 5167 { 5168 foreach (var orderlineIdToRemove in orderlinesToRemove) 5169 { 5170 order.OrderLines.RemoveLine(orderlineIdToRemove); 5171 orderlineService.Delete(orderlineIdToRemove); 5172 } 5173 } 5174 5175 orderService.ForcePriceRecalculation(order); 5176 SaveOrderChanges(order, false); 5177 5178 if (HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)] != null) 5179 { 5180 HttpContext.Current.Response.Cookies.Add(new HttpCookie(string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)){ Expires = DateTime.Now.AddDays(-1d) }); 5181 } 5182 5183 return true; 5184 } 5185 5186 private string GetAuditUserName() 5187 { 5188 var user = Dna.Frontend.Users.GetRealUser(); 5189 5190 if (user == null) 5191 { 5192 return string.Empty; 5193 } 5194 5195 return user.UserName; 5196 } 5197 5198 private Dictionary<string, string> GetShippingMethodsRelations() 5199 { 5200 var results = new Dictionary<string, string>(); 5201 foreach (Item shippingMethod in ItemList.GetItemListById(Converter.ToInt32(Pageview.Area.Item["ShippingMethodsRelations"])).Relations) 5202 { 5203 var shippingMethodWithSurcharge = (shippingMethod["ShippingMethodWithSurcharge"] ?? "").ToString(); 5204 var shippingMethodWithoutSurcharge = (shippingMethod["ShippingMethodWithoutSurcharge"] ?? "").ToString(); 5205 5206 if (results.ContainsKey(shippingMethodWithSurcharge)) 5207 { 5208 continue; 5209 } 5210 5211 results.Add(shippingMethodWithSurcharge, shippingMethodWithoutSurcharge); 5212 } 5213 return results; 5214 } 5215 5216 private bool OrderStateChangedInErp(Order order) 5217 { 5218 var erpOrderState = Dna.Ecommerce.LiveIntegration.TemplatesHelper.ReadOrderState(order); 5219 return (string.IsNullOrEmpty(erpOrderState) || !order.StateId.Equals(erpOrderState)); 5220 } 5221 } 5222 5223 @helper RenderEditOrderNoOrder() 5224 { 5225 <p>@Translate("We are unable to render this order.")</p> 5226 @SnippetStart("jsOnLoad") 5227 <text>$(".paragraphText").hide();</text> 5228 @SnippetEnd("jsOnLoad") 5229 } 5230 5231 @helper RenderEditOrderCannotEdit() 5232 { 5233 <p>@Translate("Please contact Hewitt as your order has already been processed and cannot be edited.")</p> 5234 @SnippetStart("jsOnLoad") 5235 <text>$(".paragraphText").hide();</text> 5236 @SnippetEnd("jsOnLoad") 5237 } 5238 5239 @helper RenderEditOrderFinishSaveCancelButtons(bool showSave, bool showCancel, string containerCssClass="") 5240 { 5241 <div class="col-xs-12 @containerCssClass buttonContainer"> 5242 @if (showSave) 5243 { 5244 <form class="displayInline pull-right" action="@currentPageUrl" method="post"> 5245 @RenderField(FieldSettings.CreateHiddenField(parameterFinishSave, "1")) 5246 @RenderField(FieldSettings.CreateSubmitField(Translate(" Finish and Save"), "btn-default finishSaveCancel")) 5247 </form> 5248 } 5249 5250 @if (showCancel) 5251 { 5252 <form class="displayInline pull-right" action="@currentPageUrl" method="post"> 5253 @RenderField(FieldSettings.CreateHiddenField(parameterCancel, "1")) 5254 @RenderField(FieldSettings.CreateSubmitField(Translate(" Cancel"), "btn-primary finishSaveCancel")) 5255 </form> 5256 } 5257 </div> 5258 } 5259 5260 @helper RenderEditOrder(Order order) 5261 { 5262 const string addressLabels = "hidden"; 5263 const string labelCss = "col-xs-6 col-sm-3"; 5264 const string valueCss = "col-xs-6 col-sm-9"; 5265 5266 currentPageUrl = SearchEngineFriendlyURLs.GetFriendlyUrl(string.Concat("Default.aspx?Id=", Pageview.Page.ID.ToString(CultureInfo.InvariantCulture), "&OrderID=", order.Id, "&OrderSecret=", order.Secret)); 5267 5268 var customerAddressHash = GetAddressHash(order.CustomerAddress, order.CustomerAddress2, order.CustomerCity, order.CustomerRegion, order.CustomerZip, order.CustomerCountry); 5269 var deliveryAddressHash = GetAddressHash(order.DeliveryAddress, order.DeliveryAddress2, order.DeliveryCity, order.DeliveryRegion, order.DeliveryZip, order.DeliveryCountry); 5270 var areAddessesTheSame = customerAddressHash == deliveryAddressHash; 5271 var addressTitle = areAddessesTheSame ? Translate("Billing and Shipping Address") : Translate("Billing Address"); 5272 var addressClass = areAddessesTheSame ? "col-sm-12" : " col-sm-6"; 5273 var poNumber = GetOrderCustomFieldValue(order, "PONumber"); 5274 var shippingInstructions = GetOrderCustomFieldValue(order, shippingInstructionsOrderFieldSystemName); 5275 var isEditingOrder = GetOrderCustomFieldValue(order, isEditingOrderFieldSystemName).Equals("true", StringComparison.InvariantCultureIgnoreCase); 5276 5277 if (HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)] != null) 5278 { 5279 shippingInstructions = HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)].Value; 5280 } 5281 5282 <div id="orderDetailContainer" class="orderContainer editOrder"> 5283 <div class="row generalMarginBottom"> 5284 <form class="col-xs-12 col-sm-8 quickAddForm" action="@currentPageUrl" autocomplete="off" method="post"> 5285 @RenderField(FieldSettings.CreateHiddenField("getproductinfo", "true")) 5286 @RenderField(FieldSettings.CreateHiddenField(parameterAddProduct, "1")) 5287 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterProductId, Id = "quickAddProductId"}) 5288 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterVariantId, Id = "quickAddVariantId"}) 5289 @RenderField(new FieldSettings 5290 { 5291 Type = FieldType.Text, 5292 Label = Translate("SKU"), 5293 LabelCssClass = "quickAddPartNumberContainer", 5294 SystemName = "q", 5295 Id = "quickAddPartNumber", 5296 CssClass = "quickAddPartNumber", 5297 IncludeWrapper = true, 5298 Placeholder = Translate("Enter SKU"), 5299 WrapperCssClass = "quickAddPartNumber" 5300 }) 5301 @RenderQuantitySelector(false, 99999, 2) 5302 <fieldset class="quickAddSubmitContainer pull-left"> 5303 @RenderBootstrapButton(new BootstrapButtonSettings 5304 { 5305 Label = RenderIcon("fa-shopping-cart") + " " + Translate("Add to Order"), 5306 CssClass = "quickAddSubmit btn btn-sm btn-bg", 5307 ButtonType = BootstrapButtonSettings.BootstrapButtonType.Button, 5308 Attributes = new Dictionary<string, string> {{"type", "submit"}} 5309 }) 5310 </fieldset> 5311 </form> 5312 @RenderEditOrderFinishSaveCancelButtons(isEditingOrder, true, "col-sm-4 pull-right topButton") 5313 </div> 5314 5315 <div class="row"> 5316 <header id="toggleOrderDetailsHeader" class="col-xs-12"> 5317 <h2>@RenderIcon("fa-plus-circle") @Translate("Order Details")</h2> 5318 </header> 5319 <div id="toggleOrderDetails"> 5320 <div class="col-xs-12 col-sm-6 blockContent"> 5321 <dl class="row"> 5322 @RenderDataListItem(string.Concat(Translate("Order Number"), ":"), order.Id, labelCss, valueCss, string.Empty, true) 5323 @RenderDataListItem(string.Concat(Translate("Order Date"), ":"), (order.CompletedDate != null && !order.CompletedDate.Value.ToShortDateString().Contains("1/1/0001") ? order.CompletedDate.Value : order.Date).ToString("MM/dd/yyyy"), labelCss, valueCss, string.Empty, true) 5324 @RenderDataListItem(string.Concat(Translate("Payment Method"), ":"), order.PaymentMethod, labelCss, valueCss, string.Empty, true) 5325 @if (poNumber.IsNotNullOrEmpty()) 5326 { 5327 @RenderDataListItem(string.Concat(Translate("PO Number"), ":"), poNumber, labelCss, valueCss, string.Empty, true) 5328 } 5329 @RenderDataListItem(string.Concat(Translate("Shipping Method"), ":"), order.ShippingMethod, labelCss, valueCss, string.Empty, true) 5330 </dl> 5331 </div> 5332 <div class="col-xs-12 @addressClass blockContent clear"> 5333 <h2 class="title">@addressTitle</h2> 5334 <dl> 5335 @RenderDataListItem(Translate("Name"), order.CustomerName, addressLabels, string.Empty) 5336 @RenderDataListItem(Translate("Address"), string.Concat(order.CustomerAddress, " ", order.CustomerAddress2), addressLabels, string.Empty) 5337 @RenderDataListItem(Translate("Country"), string.Concat(order.CustomerCity, ", ", order.CustomerRegion, " ", order.CustomerZip, " <br/>", order.CustomerCountry), addressLabels, string.Empty) 5338 @RenderDataListItem(Translate("Phone"), order.CustomerPhone, addressLabels, string.Empty) 5339 @RenderDataListItem(Translate("Email"), order.CustomerEmail, addressLabels, string.Empty) 5340 </dl> 5341 </div> 5342 @if (!areAddessesTheSame) 5343 { 5344 <div class="col-xs-12 col-sm-6 blockContent"> 5345 <h2 class="title">@Translate("Shipping Address")</h2> 5346 <dl> 5347 @RenderDataListItem(Translate("Name"), order.DeliveryName, addressLabels, string.Empty) 5348 @RenderDataListItem(Translate("Address"), string.Concat(order.DeliveryAddress, " ", order.DeliveryAddress2), addressLabels, string.Empty) 5349 @RenderDataListItem(Translate("Country"), string.Concat(order.DeliveryCity, ", ", order.DeliveryRegion, " ", order.DeliveryZip, " <br/>", order.DeliveryCountry), addressLabels, string.Empty) 5350 @RenderDataListItem(Translate("Phone"), order.DeliveryPhone, addressLabels, string.Empty) 5351 @RenderDataListItem(Translate("Email"), order.DeliveryEmail, addressLabels, string.Empty) 5352 </dl> 5353 </div> 5354 } 5355 @if (shippingInstructions.IsNotNullOrEmpty()) 5356 { 5357 <div id="shippingInstructions" class="col-xs-12 blockContent"> 5358 <h2 class="title">@RenderIcon("fa-edit", Translate("Shipping Instructions"), IconPosition.Right)</h2> 5359 <form class="cartChange" method="POST" action="@currentPageUrl"> 5360 @RenderField(new FieldSettings(){Type = FieldType.Textarea, SystemName = shippingInstructionsOrderFieldSystemName, Value = shippingInstructions, Attributes = new Dictionary<string, string>{{"readonly","readonly"}, {"maxlength", "62"}}}) 5361 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"))) 5362 </form> 5363 </div> 5364 } 5365 </div> 5366 </div> 5367 <div class="col-xs-12 noPadding lastStepProducts" id="productContent"> 5368 @RenderEditOrderCartContents(order.OrderLines) 5369 </div> 5370 5371 <div class="col-xs-12 totalValues noPadding"> 5372 @RenderEditOrderContentsSummary(order) 5373 </div> 5374 @RenderEditOrderFinishSaveCancelButtons(isEditingOrder, false, "noPadding") 5375 </div> 5376 5377 if (order.CustomerComment.IsNotNullOrEmpty()) 5378 { 5379 <div class="row" id="giftMessageContent"> 5380 <div class="col-xs-12"> 5381 <h2 class="title">@Translate("Gift Message")</h2> 5382 <div>@order.CustomerComment</div> 5383 </div> 5384 </div> 5385 } 5386 @SnippetStart("jsOnLoad") 5387 @: onLoadEditOrder('@errorMessage', '@Translate("Are you sure you want to delete the item")', @isEditingOrder.ToString().ToLowerInvariant()); 5388 @SnippetEnd("jsOnLoad") 5389 } 5390 5391 @helper RenderEditOrderContentsSummary(Order order, CartOutputType outputType = CartOutputType.ReadOnly) 5392 { 5393 var voucherResult = PromoCodeChecker.CheckOrderPromoCode(order.VoucherCode); 5394 var orderTaxTotal = order.OrderLines.Where(t => t.OrderLineType.Equals(OrderLineType.Tax)).Sum(s => s.Price.Price); 5395 var orderDiscount = order.OrderLines.Where(t => t.OrderLineType.Equals(OrderLineType.Discount) || t.OrderLineType.Equals(OrderLineType.ProductDiscount) && t.ParentLineId.IsNullOrEmpty()).Sum(s => s.Price.Price); 5396 5397 <div id="totalPriceContainer" class="col-xs-12 col-sm-5 noPadding pull-right noPadding-xs"> 5398 @if (voucherResult.Valid && !voucherResult.Expired && !voucherResult.Inactive && order.VoucherCode.IsNotNullOrEmpty()) 5399 { 5400 <div class="col-xs-12 noPadding"> 5401 <div class="discountContainer col-xs-12"> 5402 <div class="row"> 5403 <span class="col-xs-8 col-sm-7 noPadding">@Translate("Voucher"): @EcommerceHelpers.GetVoucherName(order.VoucherCode)</span> 5404 </div> 5405 </div> 5406 </div> 5407 } 5408 5409 @if (order.TotalPoints != null && order.TotalPoints.Value > 0) 5410 { 5411 @InternalRenderTotalAmountLine(Translate("Loyalty Points Spent"), order.TotalPoints.Value.ToString(CultureInfo.InvariantCulture), false, outputType) 5412 } 5413 5414 @if (order.RewardTotalPoints != null && order.RewardTotalPoints.Value > 0) 5415 { 5416 @InternalRenderTotalAmountLine(Translate("Loyalty Points Earned"), order.RewardTotalPoints.Value.ToString(CultureInfo.InvariantCulture), false, outputType) 5417 } 5418 5419 @if (orderDiscount < 0) 5420 { 5421 @InternalRenderTotalAmountLine(Translate("Order Savings"), Services.Currencies.Format(order.Currency, orderDiscount, true), false, outputType) 5422 } 5423 5424 @InternalRenderTotalAmountLine(Translate("Subtotal"), Services.Currencies.Format(order.Currency, order.OrderLines.Where(ol => ol.OrderLineType != OrderLineType.Discount && ol.OrderLineType != OrderLineType.Tax).Sum(olp => olp.Price.Price)), true, outputType) 5425 5426 @if (order.ShippingMethodId.IsNotNullOrEmpty() || order.ShippingMethod.IsNotNullOrEmpty()) 5427 { 5428 var shippingSurcharge = Converter.ToInt32(GetOrderCustomFieldValue(order, shippingFeeSurchargePortionOrderFieldSystemName)); 5429 var shippingMethodPrice = order.ShippingFee.Price; 5430 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 5431 { 5432 shippingMethodPrice -= shippingSurcharge; 5433 } 5434 5435 @InternalRenderTotalAmountLine(order.ShippingMethod.IsNotNullOrEmpty() ? order.ShippingMethod : order.ShippingMethodId, shippingMethodPrice > 0 ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice) : "&nbsp;", false, outputType) 5436 5437 if (shippingSurcharge > 0) 5438 { 5439 @InternalRenderTotalAmountLine(Translate("Shipping Surcharge"), Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingSurcharge), false, outputType) 5440 } 5441 } 5442 5443 @if (orderTaxTotal > 0) 5444 { 5445 @InternalRenderTotalAmountLine(Translate("Taxes"), Services.Currencies.Format(order.Currency, orderTaxTotal, true), false, outputType) 5446 } 5447 5448 @InternalRenderTotalAmountLine(Translate("Total"), order.Price.PriceFormatted, true, outputType) 5449 </div> 5450 } 5451 5452 @helper RenderEditOrderCartContents(OrderLineCollection orderLines) 5453 { 5454 <div class="showCartHeader col-sm-12 noPadding"> 5455 <div class="hidden-xs col-sm-2 col-xs-offset-6 noPadding mdAlignRight">@Translate("Dealer price")</div> 5456 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty")</div> 5457 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 5458 </div> 5459 5460 <ul class="cartProductsList"> 5461 @foreach (var orderLine in orderLines.Where(ol => ol.ParentLineId.IsNullOrEmpty())) 5462 { 5463 if (orderLine.OrderLineType != OrderLineType.Discount && orderLine.OrderLineType != OrderLineType.Tax) 5464 { 5465 @RenderEditOrderCartContentsLine(orderLines, orderLine) 5466 } 5467 } 5468 </ul> 5469 } 5470 5471 @helper RenderEditOrderCartContentsLine(OrderLineCollection orderLines, OrderLine orderLine) 5472 { 5473 var isDiscountOrderline = orderLine.DiscountId.IsNotNullOrEmpty() || orderLine.ParentLineId.IsNotNullOrEmpty(); 5474 var productUrl = isDiscountOrderline ? string.Empty : SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=" + Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "Products").ID + "&GroupID=" + orderLine.Product.PrimaryGroupId + "&ProductID=" + orderLine.ProductId); 5475 var orderLineNoteField = orderLine.get_OrderLineFieldValue(noteOrderlineFieldSystemName); 5476 var orderLineInstanceIdentifierField = orderLine.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName); 5477 var isCurrentSessionOrderline = (orderLineInstanceIdentifierField != null ? orderLineInstanceIdentifierField.Value : string.Empty).Equals(System.Web.HttpContext.Current.Session.SessionID) && orderLine.OrderLineType == OrderLineType.Product; 5478 var imageSrc = string.Empty; 5479 try 5480 { 5481 imageSrc = orderLine.ProductId.IsNotNullOrEmpty() ? Dna.Hewitt.Images.GetHewittImagePath(orderLine.Product) : string.Empty; 5482 } 5483 catch (Exception ex) 5484 { 5485 imageSrc = string.Empty; 5486 } 5487 5488 imageSrc = imageSrc.StartsWith("/files", StringComparison.InvariantCultureIgnoreCase) ? imageSrc : string.Concat("/Files", imageSrc); 5489 var productContainerCssClass = "col-xs-8 col prodName noPadding"; 5490 productContainerCssClass = string.Concat(productContainerCssClass, isDiscountOrderline ? " col-xs-offset-4" : string.Empty); 5491 5492 <li class="col-xs-12 noPadding" data-isdiscount="@isDiscountOrderline"> 5493 <div class="col-xs-12 col-sm-6 noPaddingLeft noPadding-xs"> 5494 @if (!isDiscountOrderline) 5495 { 5496 @RenderImage(new ImageSettings 5497 { 5498 Source = Images.GetImage(imageSrc, 95, 95), 5499 AltText = orderLine.ProductName, 5500 Href = productUrl, 5501 IncludeWrapper = true, 5502 WrapperElement = Sanitize.Parameter("print").IsNotNullOrEmpty() ? "div" : "figure", 5503 WrapperCssClass = "text-center col-xs-12 col-sm-4" 5504 }) 5505 } 5506 5507 <div class="@productContainerCssClass"> 5508 <h2> 5509 <a href="@productUrl"> 5510 <strong>@orderLine.ProductName</strong> 5511 @if (orderLine.ProductVariantText.IsNotNullOrEmpty()) 5512 { 5513 <br/> 5514 <small>@orderLine.ProductVariantText</small> 5515 } 5516 </a> 5517 </h2> 5518 @if (orderLine.ProductNumber.IsNotNullOrEmpty()) 5519 { 5520 <div class="itemDetails">@Translate("Item number"): @orderLine.ProductNumber</div> 5521 } 5522 5523 @if (orderLineNoteField != null) 5524 { 5525 <div class="orderlineNote"> 5526 @if (orderLineNoteField.Value.IsNotNullOrEmpty()) 5527 { 5528 <div> 5529 <strong>@orderLineNoteField.OrderLineFieldName:</strong> @orderLineNoteField.Value<br/> 5530 </div> 5531 if (isCurrentSessionOrderline) 5532 { 5533 <a href="#edit-note@( orderLine.Id)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Edit Note")</a> 5534 } 5535 } 5536 else if (isCurrentSessionOrderline) 5537 { 5538 <div> 5539 <a href="#edit-note@( orderLine.Id)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Add Note")</a> 5540 </div> 5541 } 5542 </div> 5543 if (isCurrentSessionOrderline) 5544 { 5545 <div class="hidden"> 5546 <div id="edit-note@( orderLine.Id)" style="width: 460px;"> 5547 <form class="cartChange" method="POST" action="@currentPageUrl"> 5548 @RenderField(FieldSettings.CreateHiddenField(parameterOrderLineId, orderLine.Id, String.Concat(noteOrderlineFieldSystemName, "_", parameterOrderLineId, "_", orderLine.Id))) 5549 <h2>@Translate("Product Note")</h2> 5550 @orderLineNoteField.OrderLineFieldName:<br/> 5551 @RenderField(new FieldSettings 5552 { 5553 Type = FieldType.Text, 5554 Id = string.Concat(noteOrderlineFieldSystemName, parameterOrderLineId, orderLine.Id), 5555 SystemName = parameterUpdateNote, 5556 Attributes = {{"size", orderLineNoteField.OrderLineFieldLength.ToString()}, {"maxlength", "80"}}, 5557 Value = orderLineNoteField.Value 5558 }) 5559 <br/> 5560 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"), "btn btn-bg"))<br/> 5561 </form> 5562 </div> 5563 </div> 5564 } 5565 } 5566 </div> 5567 </div> 5568 5569 <div class="col-xs-8 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight"> 5570 @if(isDiscountOrderline) 5571 { 5572 <text>&nbsp;</text> 5573 } 5574 else 5575 { 5576 if (orderLine.OrderLineType == OrderLineType.PointProduct && orderLine.UnitPoints != null) 5577 { 5578 @: @string.Format("{0} {1}", orderLine.UnitPoints, Translate(orderLine.UnitPoints.Equals(1.00) ? "point" : "points")) 5579 } 5580 else if (orderLine.Product.DefaultPrice > 0 && !orderLine.Product.DefaultPrice.Equals(orderLine.UnitPrice.Price)) 5581 { 5582 <del>@Services.Currencies.Format(orderLine.Price.Currency, orderLine.Product.DefaultPrice, true)</del> 5583 <br/> 5584 <span>@orderLine.UnitPrice.PriceFormatted</span> 5585 } 5586 else 5587 { 5588 @orderLine.UnitPrice.PriceFormatted 5589 } 5590 } 5591 </div> 5592 5593 5594 <div class="col-xs-6 col-sm-offset-0 col-sm-2 quantity noPaddingLeft mdAlignRight"> 5595 @if (isDiscountOrderline) 5596 { 5597 <text>&nbsp;</text> 5598 } 5599 else 5600 { 5601 <strong class="hidden-sm hidden-md hidden-lg pull-left">@Translate("Qty")&nbsp;&nbsp;</strong> 5602 if (isCurrentSessionOrderline) 5603 { 5604 <form class="cartChange" method="POST" action="@currentPageUrl"> 5605 @RenderField(FieldSettings.CreateHiddenField("getproductinfo", "true", String.Concat("getproductinfo_", orderLine.Id))) 5606 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterUpdateQuantity, Id = string.Concat(parameterQuantity, orderLine.Id), Value = "1"}) 5607 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterOrderLineId, Id = string.Concat(parameterOrderLineId, orderLine.Id), Value = orderLine.Id}) 5608 @InternalRenderQuantityField(999999, 999999, Convert.ToInt32(orderLine.Quantity), parameterQuantity, 10, true, orderLine.ProductVariantText.IsNotNullOrEmpty(), 0, orderLine.Id) 5609 </form> 5610 } 5611 else 5612 { 5613 <span>@orderLine.Quantity</span> 5614 } 5615 } 5616 </div> 5617 5618 <div class="col-xs-6 col-sm-2 totalPrice noPadding text-right noPadding-xs mdAlignRight"> 5619 @orderLine.Price.PriceFormatted 5620 @if (isCurrentSessionOrderline) 5621 { 5622 <form class="cartChange displayInline" method="POST" action="@currentPageUrl"> 5623 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterDeleteOrderline, Id = string.Concat(parameterDeleteOrderline, orderLine.Id), Value = "1"}) 5624 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterOrderLineId, Id = string.Concat(parameterOrderLineId, orderLine.Id), Value = orderLine.Id}) 5625 <a class="removeFromCart editOrder" href="javascript:void(0);"> 5626 @RenderIcon("fa-times") 5627 </a> 5628 </form> 5629 } 5630 </div> 5631 </li> 5632 foreach (var orderLineChild in orderLines.Where(ol => ol.ParentLineId.IsNotNullOrEmpty() && ol.ParentLineId.Equals(orderLine.Id))) 5633 { 5634 if (orderLineChild.OrderLineType != OrderLineType.Discount && orderLineChild.OrderLineType != OrderLineType.Tax) 5635 { 5636 @RenderEditOrderCartContentsLine(orderLines, orderLineChild) 5637 } 5638 } 5639 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 5640 @using Dynamicweb.Core 5641 @using Dynamicweb.Rendering 5642 @using Dna.Frontend.UI 5643 @using System 5644 @using System.Web 5645 @using System.Collections.Generic 5646 @using System.Data.SqlTypes 5647 @using System.Globalization 5648 @using Dynamicweb.Frontend 5649 @using System.Linq 5650 @using Dna.Frontend.Forms 5651 @using Dna.Validation 5652 @using Dynamicweb.Ecommerce 5653 @using Dynamicweb.Forms 5654 @using System.Web.Script.Serialization 5655 @using Dynamicweb.Security.UserManagement 5656 @{ 5657 @helper RenderActionCc(IconAction action, string href = "", string title = "", string onClickConfirm = "") 5658 { 5659 var attributes = new Dictionary<string, string>(); 5660 5661 if (title.IsNotNullOrEmpty()) 5662 { 5663 attributes.Add("title", title); 5664 } 5665 if (onClickConfirm.IsNotNullOrEmpty()) 5666 { 5667 attributes.Add("onclick", "return confirm('" + onClickConfirm + "');"); 5668 } 5669 if (href.IsNotNullOrEmpty()) 5670 { 5671 attributes.Add("href", href); 5672 } 5673 @RenderActionCc(action, href, attributes) 5674 } 5675 5676 @helper RenderActionCc(IconAction action, string href, Dictionary<string, string> attributes) 5677 { 5678 var icon = string.Empty; 5679 var linkAttributes = string.Empty; 5680 var label = Translate(action.ToString()); 5681 5682 switch (action) 5683 { 5684 case IconAction.Add: 5685 break; 5686 case IconAction.View: 5687 icon = "fa-eye"; 5688 break; 5689 case IconAction.Edit: 5690 break; 5691 case IconAction.Cancel: 5692 case IconAction.Remove: 5693 icon = "fa-times"; 5694 break; 5695 case IconAction.Delete: 5696 icon = "fa-trash"; 5697 break; 5698 case IconAction.Print: 5699 icon = "fa-print"; 5700 attributes.Add("target", "_blank"); 5701 label = string.Empty; 5702 break; 5703 case IconAction.Save: 5704 break; 5705 case IconAction.Reset: 5706 break; 5707 case IconAction.Undo: 5708 break; 5709 case IconAction.Reorder: 5710 icon = "fa-repeat"; 5711 break; 5712 case IconAction.SetDefault: 5713 icon = "fa-times"; 5714 label = string.Empty; 5715 break; 5716 case IconAction.IsDefault: 5717 icon = "fa-check"; 5718 label = string.Empty; 5719 break; 5720 default: 5721 throw new NotSupportedException("An action is needed to render this helper!"); 5722 } 5723 if (icon.IsNotNullOrEmpty()) 5724 { 5725 if (href.IsNotNullOrEmpty()) 5726 { 5727 @GetHtmlElement("a", GetAttributes(attributes)) 5728 @RenderIcon(icon, label) 5729 @GetHtmlElement("a", true) 5730 } 5731 else if (label.IsNullOrEmpty()) 5732 { 5733 @RenderIcon(icon) 5734 } 5735 } 5736 5737 } 5738 5739 @helper RenderTabWithOrdersList(List<LoopItem> ordersLoop, string noOrdersMessage = "", int sendOrderPage = 0, string detailPageBase = "") 5740 { 5741 var userDisallowOrderingFieldValue = Dna.Frontend.Users.GetRealUser().CustomFieldValues.First(x => x.CustomField.SystemName == "AccessUser_DisallowOrdering").Value; 5742 var isUserOrderDisallowed = (userDisallowOrderingFieldValue != null && userDisallowOrderingFieldValue.ToString() == "True"); 5743 var sendOrderParagraphId = GetParagraphIdFromCc(); 5744 var excludedColumns = new string[] {"OrderSecret", "BackOrdered", "IsEditing"}; 5745 <div class="col-xs-12 noPadding" id="ordersListContainer"> 5746 @if (ordersLoop.Any()) 5747 { 5748 var editPageBase = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("EditOrder")) + "?OrderID="; 5749 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 5750 <table id="myOrdersTable" class="col-xs-12 noPadding text-left evenTable"> 5751 @RenderDataListTableHead(excludedColumns, true) 5752 <tbody> 5753 @foreach (var row in ordersLoop) 5754 { 5755 var orderId = row.GetString("OrderID"); 5756 var detailPage = string.Concat(detailPageBase, "?OrderId=", orderId, "&OrderSecret=", row.GetString("OrderSecret")); 5757 var editPage = editPageBase + orderId + "&OrderSecret=" + row.GetString("OrderSecret") + "&edit=1"; 5758 var print = detailPage + "&amp;print=true"; 5759 var resendOrder = SearchEngineFriendlyURLs.GetFriendlyUrl(sendOrderPage) + "?CC" + sendOrderParagraphId + "=Resend&OrderID=" + orderId; 5760 <tr> 5761 @foreach (var rowValue in row.GetLoop("Row").Where(c => !excludedColumns.Contains(c.GetString("Row.ColumnName")))) 5762 { 5763 var columnName = rowValue.GetString("Row.ColumnName"); 5764 <td data-th="@Translate(columnName)"> 5765 @if (columnName.Contains("Price")) 5766 { 5767 @Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, rowValue.GetDouble("Row.Value")) 5768 } 5769 else if (columnName == "OrderID") 5770 { 5771 <a href="@detailPage">@rowValue.GetString("Row.Value")</a> 5772 } 5773 else 5774 { 5775 switch (rowValue.GetValue("Row.Value").GetType().ToString()) 5776 { 5777 case "System.DateTime": 5778 @rowValue.GetDate("Row.Value").ToString("MM/dd/yyyy") 5779 break; 5780 case "System.Double": 5781 @rowValue.GetDouble("Row.Value") 5782 break; 5783 default: 5784 @rowValue.GetString("Row.Value") 5785 break; 5786 } 5787 } 5788 </td> 5789 } 5790 @{ 5791 if (!Dna.Hewitt.Helpers.IsUserBlockedInTheErp()) 5792 { 5793 5794 <td data-th="@Translate("Actions")" class="actions" data-th='@Translate("Actions")'> 5795 @if (!isUserOrderDisallowed && isB2B && Pageview.Page.ID.Equals(GetPageIdByNavigationTag("openOrders"))) 5796 { 5797 @RenderBootstrapButton(new BootstrapButtonSettings 5798 { 5799 Label = "Edit", 5800 CssClass = "btn-link edit-order-button", 5801 IconCssClass = "fa-edit", 5802 Attributes = new Dictionary<string, string> 5803 { 5804 {"title", Translate("Edit list")}, 5805 {"data-href", editPage}, 5806 {"data-toggle", "modal"}, 5807 {"data-target", "#modal-edit-order"} 5808 } 5809 }) 5810 } 5811 @if (sendOrderParagraphId> 0) 5812 { 5813 @RenderBootstrapButton(new BootstrapButtonSettings 5814 { 5815 CssClass = "noPadding viewOrderBtn", 5816 Label = Translate("View"), 5817 Href = detailPage, 5818 ButtonType = BootstrapButtonSettings.BootstrapButtonType.Anchor 5819 }) 5820 ; 5821 @RenderBootstrapButton(new BootstrapButtonSettings 5822 { 5823 Label = "Reorder", 5824 CssClass = "reorderBtn noPaddingRight", 5825 IconCssClass = "fa-repeat", 5826 Attributes = new Dictionary<string, string> 5827 { 5828 {"data-href", "/Default.aspx?ID=" + sendOrderPage + "&CC" + sendOrderParagraphId + "=Orders&ReorderID=" + row.GetString("OrderID") + "&redirect=false"} 5829 } 5830 }) 5831 @RenderAction(IconAction.Print, print) 5832 <a class="emailResend" 5833 data-resend-href="@resendOrder" 5834 href="@( SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("OrderEmailAddressesPopup")) + "?CC" + sendOrderParagraphId + "=Resend&OrderID=" + orderId)"> 5835 @RenderIcon("fa-envelope") 5836 </a> 5837 } 5838 </td> 5839 } 5840 } 5841 </tr> 5842 5843 } 5844 </tbody> 5845 </table> 5846 @RenderPaging( 5847 GetInteger("DwPaging.PageCount"), 5848 "DWPagingPageNum", 5849 GetString("DwPaging.PreviousPageLink"), 5850 GetString("DwPaging.NextPageLink"), 5851 GetInteger("DwPaging.CurrentPage") 5852 ) 5853 } 5854 else 5855 { 5856 @noOrdersMessage 5857 } 5858 </div> 5859 } 5860 5861 5862 @helper RenderReportTabFilters(List<LoopItem> reportsListLoop, string[] dropdownFilterFields = null) 5863 { 5864 dropdownFilterFields = dropdownFilterFields ?? new string[0]; 5865 5866 var today = DateTime.Now; 5867 var currentMonth = new DateTime(today.Year, today.Month, 1); 5868 var lastDayOfCurrentMonth = currentMonth.AddMonths(1).AddDays(-1); 5869 var firstDayOfLastMonth = currentMonth.AddMonths(-1); 5870 var lastDayOfLastMonth = currentMonth.AddDays(-1); 5871 var lastTwoMonths = currentMonth.AddMonths(-2); 5872 var lastThreeMonths = currentMonth.AddMonths(-3); 5873 var lastTwelveMonths = currentMonth.AddMonths(-12); 5874 var searchOrdersPageId = Pageview.Page.ID; 5875 5876 var reqDateFrom = Sanitize.Parameter("startdate", ParameterType.Date); 5877 var reqStateFilter = Sanitize.Parameter("stateFilter"); 5878 5879 var queryParameters = HttpUtility.ParseQueryString(Dynamicweb.Context.Current.Request.Url.Query); 5880 queryParameters = Dna.UrlServices.Helpers.UpdateQueryStringKeyValue(queryParameters, "ID", GetPageIdByNavigationTag(Pageview.Page.ID.Equals(GetPageIdByNavigationTag("OrdersOnReports")) ? "OrdersCSV" : "CommissionsCSV").ToString()); 5881 5882 var dateFilter = new FieldSettings 5883 { 5884 Type = FieldType.Select, 5885 Id = "dateFilter", 5886 SystemName = "dateFilter", 5887 CssClass = "selectpicker", 5888 IncludeWrapper = true, 5889 WrapperCssClass = "col-xs-12 col-sm-3 noPadding pull-left", 5890 FieldOptionsList = new List<FieldOption>() 5891 }; 5892 5893 dateFilter.FieldOptionsList.Add(new FieldOption 5894 { 5895 Label = Translate("Current Month"), 5896 Value = "CurrentMonth", 5897 IsSelected = string.Compare(reqDateFrom, currentMonth.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5898 Attributes = 5899 { 5900 {"data-fromMonth", currentMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5901 {"data-toMonth", lastDayOfCurrentMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5902 } 5903 }); 5904 5905 dateFilter.FieldOptionsList.Add(new FieldOption 5906 { 5907 Label = Translate("Last Month"), 5908 Value = "LastMonth", 5909 IsSelected = string.Compare(reqDateFrom, firstDayOfLastMonth.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5910 Attributes = 5911 { 5912 {"data-fromMonth", firstDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5913 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5914 } 5915 }); 5916 5917 dateFilter.FieldOptionsList.Add(new FieldOption 5918 { 5919 Label = Translate("Last 2 Months"), 5920 Value = "Last2Months", 5921 IsSelected = string.Compare(reqDateFrom, lastTwoMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5922 Attributes = 5923 { 5924 {"data-fromMonth", lastTwoMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture)}, 5925 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5926 } 5927 }); 5928 5929 dateFilter.FieldOptionsList.Add(new FieldOption 5930 { 5931 Label = Translate("Last 3 Months"), 5932 Value = "Last3Months", 5933 IsSelected = string.Compare(reqDateFrom, lastThreeMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5934 Attributes = 5935 { 5936 {"data-fromMonth", lastThreeMonths.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5937 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5938 } 5939 }); 5940 5941 dateFilter.FieldOptionsList.Add(new FieldOption 5942 { 5943 Label = Translate("Last 12 Months"), 5944 Value = "Last12Months", 5945 IsSelected = string.Compare(reqDateFrom, lastTwelveMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0 , 5946 Attributes = 5947 { 5948 {"data-fromMonth", lastTwelveMonths.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5949 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5950 } 5951 }); 5952 5953 dateFilter.FieldOptionsList.Add(new FieldOption 5954 { 5955 Label = Translate("All"), 5956 Value = "All", 5957 IsSelected = reqDateFrom.IsNullOrEmpty() || string.Compare(reqDateFrom, SqlDateTime.MinValue.Value.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0 , 5958 Attributes = 5959 { 5960 {"data-fromMonth", SqlDateTime.MinValue.Value.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5961 {"data-toMonth", SqlDateTime.MaxValue.Value.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5962 } 5963 }); 5964 5965 var stateFilter = new FieldSettings 5966 { 5967 Type = FieldType.Select, 5968 Id = "stateFilter", 5969 SystemName = "stateFilter", 5970 CssClass = "selectpicker", 5971 IncludeWrapper = true, 5972 WrapperCssClass = "col-xs-12 col-sm-3 noPadding pull-left", 5973 FieldOptionsList = new List<FieldOption>() 5974 }; 5975 5976 stateFilter.FirstHardcodedOptionLabel = Translate("Select State"); 5977 stateFilter.FirstHardcodedOptionValue = ""; 5978 5979 foreach (var state in Dynamicweb.Ecommerce.Orders.OrderState.GetAllOrderStates()) 5980 { 5981 if (state.Id != "OS1" && state.Id != "OS9" && state.Id != "OS11") 5982 { 5983 continue; 5984 } 5985 5986 stateFilter.FieldOptionsList.Add(new FieldOption() 5987 { 5988 Label = state.Name, 5989 Value = state.Id, 5990 IsSelected = string.Compare(reqStateFilter, state.Id, StringComparison.CurrentCultureIgnoreCase) == 0 5991 }); 5992 } 5993 5994 var searchBox = new FieldSettings 5995 { 5996 Type = FieldType.Search, 5997 Placeholder = Translate("Search"), 5998 Id = "searchData", 5999 WrapperCssClass = "col-xs-12 col-sm-6 noPaddingLeft", 6000 IncludeWrapper = true, 6001 SystemName = "SearchText", 6002 Value = Sanitize.Parameter("SearchText", ParameterType.LongText) 6003 }; 6004 6005 <form action="@SearchEngineFriendlyURLs.GetFriendlyUrl(searchOrdersPageId)" id="searchFormReports" class="col-xs-12 noPadding" method="post"> 6006 @RenderField(FieldSettings.CreateHiddenField("ViewPID", Pageview.CurrentParagraph.ID.ToString())) 6007 @RenderField(FieldSettings.CreateHiddenField("DWPagingPageNum", Sanitize.Parameter("DWPagingPageNum").IsNotNullOrEmpty() ? Sanitize.Parameter("DWPagingPageNum") : "1")) 6008 @RenderField(FieldSettings.CreateHiddenField("sortby", Sanitize.Parameter("sortby"))) 6009 @RenderField(FieldSettings.CreateHiddenField("sortorder", Sanitize.Parameter("sortorder"))) 6010 @foreach (string f in dropdownFilterFields) 6011 { 6012 @RenderField(FieldSettings.CreateHiddenField(f, Sanitize.Parameter(f, "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]"))) 6013 } 6014 6015 @RenderField(new FieldSettings() 6016 { 6017 Type = FieldType.Hidden, 6018 SystemName = "setPaidCommissions", 6019 Attributes = new Dictionary<string, string> 6020 { 6021 {"disabled", "disabled"} 6022 } 6023 }) 6024 @RenderField(FieldSettings.CreateHiddenField("startDate")) 6025 @RenderField(FieldSettings.CreateHiddenField("endDate")) 6026 @if (Pageview.Page.ID.Equals(GetPageIdByNavigationTag("CommissionsOnReports"))) 6027 { 6028 var totalCommissions = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, reportsListLoop.Any() ? reportsListLoop.First().GetDouble("TotalCommission") : 0); 6029 <p class="col-xs-12 col-sm-6 noPadding pull-left">@Translate("Total Commissions in this time period:") <strong>@totalCommissions</strong></p> 6030 } 6031 @RenderBootstrapButton(new BootstrapButtonSettings 6032 { 6033 Id = "downloadDataList", 6034 CssClass = "btn-bg pull-right", 6035 Label = Translate("Download to Excel/CSV"), 6036 Attributes = new Dictionary<string, string>{ 6037 {"data-action", SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag(Pageview.Page.ID.Equals(GetPageIdByNavigationTag("OrdersOnReports")) ? "OrdersCSV" : "CommissionsCSV"))} 6038 }, 6039 Href = Dna.UrlServices.Helpers.BuildUri(Dna.UrlServices.Helpers.GetCurrentUrl(true, true), queryParameters).PathAndQuery 6040 }) 6041 6042 <div class="col-xs-12 noPadding dataListFilters generalMarginBottom"> 6043 <span class="col-xs-12 noPadding">@Translate("Date Filter")</span> 6044 @RenderField(dateFilter) 6045 @if (Pageview.Page.ID.Equals(GetPageIdByNavigationTag("CommissionsOnReports"))) 6046 { 6047 @RenderField(stateFilter) 6048 } 6049 <div class="col-xs-12 col-sm-6 noPadding text-right pull-right"> 6050 @RenderField(searchBox) 6051 @RenderBootstrapButton(new BootstrapButtonSettings {IconCssClass = "fa-search", ButtonType = BootstrapButtonSettings.BootstrapButtonType.Button}) 6052 </div> 6053 </div> 6054 </form> 6055 } 6056 6057 @helper RenderTabWithCommissionsList(List<LoopItem> reportsListLoop , string detailPageBase) 6058 { 6059 var excludedColumns = new string[] {"OrderSecret", "TotalCommission"}; 6060 6061 <table id="myOrdersTable" class="col-xs-12 noPadding text-left evenTable"> 6062 @RenderDataListTableHead(excludedColumns) 6063 <tbody> 6064 @foreach (var row in reportsListLoop) 6065 { 6066 var orderId = row.GetString("OrderID"); 6067 var orderSecret = row.GetString("OrderSecret"); 6068 var detailPage = string.Concat(detailPageBase, "?OrderId=", orderId, "&OrderSecret=", orderSecret); 6069 <tr> 6070 @foreach (var rowValue in row.GetLoop("Row").Where(c => !excludedColumns.Contains(c.GetString("Row.ColumnName")))) 6071 { 6072 var columnName = rowValue.GetString("Row.ColumnName"); 6073 <td data-th="@Translate(columnName)"> 6074 @if (columnName.Contains("Amount") || columnName.Contains("QualifyingItems") || columnName.Equals("Commission")) 6075 { 6076 @Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, rowValue.GetDouble("Row.Value")) 6077 } 6078 else if (columnName == "OrderID" && orderSecret.IsNotNullOrEmpty()) 6079 { 6080 <a href="@detailPage">@rowValue.GetString("Row.Value")</a> 6081 } 6082 else if (columnName == "PaidCommission") 6083 { 6084 @RenderField(new FieldSettings 6085 { 6086 Type = FieldType.Checkbox, 6087 Label = "&nbsp", 6088 IsChecked = rowValue.GetBoolean("Row.Value"), 6089 SystemName = string.Concat("PaidCommission", orderId), 6090 Value = orderId 6091 }) 6092 } 6093 else 6094 { 6095 switch (rowValue.GetValue("Row.Value").GetType().ToString()) 6096 { 6097 case "System.DateTime": 6098 @rowValue.GetDate("Row.Value").ToString("MM/dd/yyyy") 6099 break; 6100 case "System.Double": 6101 @rowValue.GetDouble("Row.Value") 6102 break; 6103 default: 6104 @rowValue.GetString("Row.Value") 6105 break; 6106 } 6107 } 6108 </td> 6109 } 6110 </tr> 6111 } 6112 </tbody> 6113 <tfoot> 6114 <tr> 6115 <td class="text-right" colspan="11"> 6116 @RenderField(new FieldSettings 6117 { 6118 Type = FieldType.Checkbox, 6119 Label = Translate("Toggle all"), 6120 SystemName = "TogglePaidCommission" 6121 }) 6122 @RenderBootstrapButton(new BootstrapButtonSettings 6123 { 6124 ButtonType = BootstrapButtonSettings.BootstrapButtonType.Button, 6125 Label = Translate("Apply"), 6126 Id = "setPaidCommissionsButton", 6127 CssClass = "btn-default" 6128 }) 6129 </td> 6130 </tr> 6131 </tfoot> 6132 </table> 6133 } 6134 6135 @helper RenderTabWithOrderReportsList(List<LoopItem> reportsListLoop ,string detailPageBase, string[] dropdownFilterFields = null) 6136 { 6137 var excludedColumns = new string[] {"OrderSecret"}; 6138 6139 <table id="myOrdersTable" class="col-xs-12 noPadding text-left evenTable"> 6140 @RenderDataListTableHead(excludedColumns, false, dropdownFilterFields) 6141 <tbody> 6142 @foreach (var row in reportsListLoop) 6143 { 6144 var orderId = row.GetString("OrderID"); 6145 var orderSecret = row.GetString("OrderSecret"); 6146 var detailPage = string.Concat(detailPageBase, "?OrderId=", orderId, "&OrderSecret=", orderSecret); 6147 <tr> 6148 @foreach (var rowValue in row.GetLoop("Row").Where(c => !excludedColumns.Contains(c.GetString("Row.ColumnName")))) 6149 { 6150 6151 var columnName = rowValue.GetString("Row.ColumnName"); 6152 var columnHeading = Translate(string.Concat("Data List ", columnName)); 6153 <td data-th="@columnHeading"> 6154 @if (columnName.Contains("Price")) 6155 { 6156 @Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, rowValue.GetDouble("Row.Value")) 6157 } 6158 else if (columnName == "OrderID" && orderSecret.IsNotNullOrEmpty()) 6159 { 6160 <a href="@detailPage">@rowValue.GetString("Row.Value")</a> 6161 } 6162 else if (columnName == "OrderWeight") 6163 { 6164 <text> 6165 @string.Concat(rowValue.GetString("Row.Value"), " ", Dynamicweb.Configuration.SystemConfiguration.Instance.GetValue("/Globalsettings/Ecom/Unit/Weight")) 6166 </text> 6167 } 6168 else 6169 { 6170 switch (rowValue.GetValue("Row.Value").GetType().ToString()) 6171 { 6172 case "System.DateTime": 6173 if(rowValue.GetDate("Row.Value") != Convert.ToDateTime("01/01/0001 12:00:00 AM")) 6174 {@rowValue.GetDate("Row.Value").ToString("MM/dd/yyyy")} 6175 break; 6176 case "System.Double": 6177 @rowValue.GetDouble("Row.Value") 6178 break; 6179 default: 6180 @rowValue.GetString("Row.Value") 6181 break; 6182 } 6183 } 6184 </td> 6185 } 6186 </tr> 6187 } 6188 </tbody> 6189 </table> 6190 } 6191 6192 @helper RenderDataListTableHead(string[] excludedColumns = null, bool showActions = false, string[] dropdownFilterFields = null) 6193 { 6194 excludedColumns = excludedColumns ?? new string[0]; 6195 dropdownFilterFields = dropdownFilterFields ?? new string[0]; 6196 6197 <thead class="orderList"> 6198 <tr> 6199 @foreach (var column in GetLoop("Columns").Where(c => !excludedColumns.Contains(c.GetString("Column.Name")))) 6200 { 6201 var thAttributes = dropdownFilterFields.Contains(column.GetString("Column.Name")) ? string.Concat("data-filter=\"", column.GetString("Column.Name"), "\"") : "class=\"no-filter\""; 6202 <th @thAttributes nowrap><span class="displayBlock">@RenderTableHeading(Translate(string.Concat("Data List ",column.GetString("Column.Name"))))</span>@RenderTableHeading(string.Empty, column.GetString("Column.Name"), "DataList")</th> 6203 } 6204 @if(showActions) 6205 { 6206 <th>@RenderTableHeading(Translate("Actions"))</th> 6207 } 6208 </tr> 6209 </thead> 6210 } 6211 } 6212 @functions 6213 { 6214 6215 public string GetDistinctFilterValues() 6216 { 6217 if (!Pageview.Page.ID.Equals(GetPageIdByNavigationTag("OrdersOnReports"))) 6218 return string.Empty; 6219 { 6220 } 6221 6222 var submitedStatus = Sanitize.Parameter("Status", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").IsNotNullOrEmpty() ? Sanitize.Parameter("Status", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").Split(new []{"','"}, StringSplitOptions.RemoveEmptyEntries) : new string[0]; 6223 var submitedDealerName = Sanitize.Parameter("DealerName", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").IsNotNullOrEmpty() ? Sanitize.Parameter("DealerName", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").Split(new []{"','"}, StringSplitOptions.RemoveEmptyEntries) : new string[0]; 6224 var submitedBackordered = Sanitize.Parameter("Backordered", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").IsNotNullOrEmpty() ? Sanitize.Parameter("Backordered", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").Split(new []{"','"}, StringSplitOptions.RemoveEmptyEntries) : new string[0]; 6225 var submitedShippingMethod = Sanitize.Parameter("ShippingMethod", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").IsNotNullOrEmpty() ? Sanitize.Parameter("ShippingMethod", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").Split(new []{"','"}, StringSplitOptions.RemoveEmptyEntries) : new string[0]; 6226 var submitedDealerState = Sanitize.Parameter("DealerState", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").IsNotNullOrEmpty() ? Sanitize.Parameter("DealerState", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").Split(new []{"','"}, StringSplitOptions.RemoveEmptyEntries) : new string[0]; 6227 var submitedSalesRep = Sanitize.Parameter("SalesRep", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").IsNotNullOrEmpty() ? Sanitize.Parameter("SalesRep", "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]").Split(new []{"','"}, StringSplitOptions.RemoveEmptyEntries) : new string[0]; 6228 var reqSearchText = Sanitize.Parameter("SearchText", ParameterType.LongText); 6229 var reqDateFrom = Sanitize.Parameter("startdate", ParameterType.Date); 6230 var reqDateTo = Sanitize.Parameter("endDate", ParameterType.Date); 6231 reqDateFrom = reqDateFrom.IsNotNullOrEmpty() ? reqDateFrom : "01/01/1753"; 6232 reqDateTo = reqDateTo.IsNotNullOrEmpty() ? reqDateTo : "12/31/9999"; 6233 6234 var results = new Dictionary<string, Dictionary<string, bool>>(); 6235 results.Add("Status", new Dictionary<string, bool>()); 6236 results.Add("DealerName", new Dictionary<string, bool>()); 6237 results.Add("Backordered", new Dictionary<string, bool>()); 6238 results.Add("ShippingMethod", new Dictionary<string, bool>()); 6239 results.Add("DealerState", new Dictionary<string, bool>()); 6240 results.Add("SalesRep", new Dictionary<string, bool>()); 6241 6242 var distinctFilterValues = Dynamicweb.Data.Database.CreateDataReader("SELECT DISTINCT ISNULL(states.OrderStateName, '') AS Status, ISNULL(customer.AccessUserName, '') AS DealerName, ISNULL(o.BackOrdered, 0) AS Backordered, ISNULL(o.OrderShippingMethod, '') AS ShippingMethod, customer.AccessUserState AS DealerState, salesRep.AccessUserName AS SalesRep FROM EcomOrders o "+ 6243 "JOIN EcomOrderStates states ON o.OrderStateID = states.OrderStateID "+ 6244 "JOIN AccessUser customer ON customer.AccessUserCustomerNumber = o.OrderCustomerNumber AND ISNULL(customer.AccessUser_SalesRepId, '') <> '' " + 6245 "LEFT OUTER JOIN AccessUser loginUser ON loginUser.AccessUserID = o.OrderSecondaryUserID " + 6246 "JOIN AccessUser salesRep ON customer.AccessUser_SalesRepId=salesRep.AccessUser_SalesRepSalesRepId AND ISNULL(customer.AccessUser_SalesRepId, '') <> '' "+ 6247 "WHERE o.OrderDate IS NOT NULL " + 6248 "AND o.OrderIsLedgerEntry=0 " + 6249 "AND o.OrderDeleted=0 " + 6250 "AND customer.AccessUser_CustomerType IN ('B2B','B2BLegEligible','GLMP') " + 6251 "AND o.OrderDate >= CONVERT(datetime, '" + reqDateFrom + "', 101) " + 6252 "AND o.OrderDate <= CONVERT(datetime, '" + reqDateTo + "', 101) " + 6253 "AND (" + 6254 "states.OrderStateName LIKE '%" + reqSearchText + "%' " + 6255 "OR customer.AccessUser_SalesRepId LIKE '%" + reqSearchText + "%' " + 6256 "OR o.OrderShippingMethod LIKE '%" + reqSearchText + "%' " + 6257 "OR o.OrderCustomerName LIKE '%" + reqSearchText + "%' " + 6258 "OR o.OrderID LIKE '%" + reqSearchText + "%' " + 6259 "OR loginUser.AccessUserName LIKE '%" + reqSearchText + "%' " + 6260 "OR o.PONumber LIKE '%" + reqSearchText + "%'" + 6261 ")"); 6262 6263 while (distinctFilterValues.Read()) 6264 { 6265 var status = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["Status"].ToString().ToLowerInvariant()).Replace("'", "''"); 6266 var dealerName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["DealerName"].ToString().ToLowerInvariant()).Replace("'", "''"); 6267 var backordered = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["Backordered"].ToString().ToLowerInvariant()).Replace("'", "''"); 6268 var shippingMethod = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["ShippingMethod"].ToString().ToLowerInvariant()).Replace("'", "''"); 6269 var dealerState = distinctFilterValues["DealerState"].ToString().Replace("'", "''"); 6270 var salesRep = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["SalesRep"].ToString().ToLowerInvariant()).Replace("'", "''"); 6271 6272 if (!results["Status"].ContainsKey(status) && status.IsNotNullOrEmpty()) 6273 { 6274 results["Status"].Add(status, (!submitedStatus.Any() || submitedStatus.Contains(status))); 6275 } 6276 6277 if (!results["DealerName"].ContainsKey(dealerName) && dealerName.IsNotNullOrEmpty()) 6278 { 6279 results["DealerName"].Add(dealerName, (!submitedDealerName.Any() || submitedDealerName.Contains(dealerName))); 6280 } 6281 6282 if (!results["Backordered"].ContainsKey(backordered) && backordered.IsNotNullOrEmpty()) 6283 { 6284 results["Backordered"].Add(backordered, (!submitedBackordered.Any() || submitedBackordered.Contains(backordered))); 6285 } 6286 6287 if (!results["ShippingMethod"].ContainsKey(shippingMethod) && shippingMethod.IsNotNullOrEmpty()) 6288 { 6289 results["ShippingMethod"].Add(shippingMethod, (!submitedShippingMethod.Any() || submitedShippingMethod.Contains(shippingMethod))); 6290 } 6291 6292 if (!results["DealerState"].ContainsKey(dealerState) && dealerState.IsNotNullOrEmpty()) 6293 { 6294 results["DealerState"].Add(dealerState, (!submitedDealerState.Any() || submitedDealerState.Contains(dealerState))); 6295 } 6296 6297 if (!results["SalesRep"].ContainsKey(salesRep) && salesRep.IsNotNullOrEmpty()) 6298 { 6299 results["SalesRep"].Add(salesRep, (!submitedSalesRep.Any() || submitedSalesRep.Contains(salesRep))); 6300 } 6301 } 6302 6303 return new JavaScriptSerializer().Serialize(results); 6304 } 6305 } 6306 @{ 6307 var ordersLoop = GetLoop("Rows"); 6308 var editingOrders = ordersLoop.Where(o => o.GetString("IsEditing").Equals("true", StringComparison.InvariantCultureIgnoreCase)).ToList(); 6309 var noOrdersMessage = Pageview.Page.ID.Equals(GetPageIdByNavigationTag("openOrders")) ? Translate("No open orders found") : Translate("No processed orders found"); 6310 var viewOrderPageId = GetPageIdByNavigationTag("ViewOrder"); 6311 var sendOrderPage = GetPageIdByNavigationTag("SendOrder"); 6312 var detailPageBase = SearchEngineFriendlyURLs.GetFriendlyUrl(viewOrderPageId); 6313 if (editingOrders.Any()) 6314 { 6315 foreach (var order in editingOrders) 6316 { 6317 CancelOrder(orderService.GetById(order.GetString("OrderID"))); 6318 } 6319 6320 <script> 6321 document.body.style.display = "none"; 6322 window.location.href = window.location.href; 6323 </script> 6324 } 6325 6326 <div id="tabsContainer" class="col-xs-12 noPadding tabsOrdersListContainer"> 6327 @RenderNavigation(new 6328 { 6329 StartLevel = 4, 6330 EndLevel = 4, 6331 Template = "liClean.xslt", 6332 ID = "reportsMenu", 6333 }) 6334 @RenderTabWithOrdersList(ordersLoop,noOrdersMessage,sendOrderPage,detailPageBase) 6335 </div> 6336 6337 } 6338 @SnippetStart("jsVariables") 6339 var successMessage = ('@Translate("Order email was sent successfully.")'); 6340 var errorMessage = ('@Translate("Something went wrong")'); 6341 @SnippetEnd("jsVariables") 6342 @SnippetStart("jsOnLoad") 6343 onLoadOrderList("@Translate("Items have been added to the cart")", "@("CCResend" + GetParagraphIdFromCc() + "=successfully")"); 6344 @SnippetEnd("jsOnLoad")