Latest Orders

Open
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_e7a4caf6bc444569a2bf3bde463808e3.<>c__DisplayClass204_0.b__0(TextWriter __razor_helper_writer) in c:\Domains\Sites\hewittrad.com\Files\Templates\Designs\Hewitt\DataManagement\Publishings\Custom\Orders.cshtml:line 5734
   at CompiledRazorTemplates.Dynamic.RazorEngine_e7a4caf6bc444569a2bf3bde463808e3.Execute() in c:\Domains\Sites\hewittrad.com\Files\Templates\Designs\Hewitt\DataManagement\Publishings\Custom\Orders.cshtml:line 6322
   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 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 3614 @using System 3615 @using System.Linq 3616 @using System.Collections.Generic 3617 @using System.Globalization 3618 @using System.Web 3619 @using Dynamicweb.Core 3620 @using Dynamicweb.Forms 3621 @using Dynamicweb.Rendering 3622 @using Dynamicweb.Frontend 3623 @using Dynamicweb.Ecommerce.Orders 3624 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 3625 @using Dynamicweb.Security.UserManagement 3626 @using Dna.Frontend 3627 @using Dna.Frontend.Forms 3628 @using Dna.Frontend.UI 3629 @using Dna.UrlServices 3630 @using Dna.Validation 3631 @using Dynamicweb.Ecommerce 3632 @{ 3633 @helper RenderCheckoutCompleteActionsCustom(bool isCheckoutFlow = true, int sendOrderPageId = 0, string orderId = "") 3634 { 3635 var printUrl = HttpContext.Current.Request.RawUrl + "&amp;print=true"; 3636 var pdfUrl = printUrl + "&amp;pdf=true&amp;filename=Order_" + orderId + ".pdf"; 3637 var sendOrderParagraphId = GetParagraphIdFromCc(); 3638 var addressPopupHref = "/Default.aspx?ID=" + GetPageIdByNavigationTag("OrderEmailAddressesPopup"); 3639 var resendOrder = SearchEngineFriendlyURLs.GetFriendlyUrl(sendOrderPageId) + "?CC" + sendOrderParagraphId + "=Resend&OrderID=" + orderId; 3640 <div class="checkoutActions continueButton col-xs-12 hidden-xs"> 3641 @RenderBootstrapButton(new BootstrapButtonSettings 3642 { 3643 Label = Translate(" Print"), 3644 Href = printUrl, 3645 CssClass = "btn-default pull-left print", 3646 Target = "_blank", 3647 IconCssClass = "fa-print" 3648 }) 3649 @RenderBootstrapButton(new BootstrapButtonSettings 3650 { 3651 Label = Translate(" Download as PDF"), 3652 Href = pdfUrl, 3653 CssClass = "btn-default pull-left dwnPdf", 3654 Target = "_blank", 3655 IconCssClass = "fa-download" 3656 }) 3657 @if (User.IsExtranetUserLoggedIn() || IsBoatlifterSite()) 3658 { 3659 @RenderBootstrapButton(new BootstrapButtonSettings 3660 { 3661 Label = Translate(" Email Order"), 3662 Href = addressPopupHref, 3663 CssClass = "btn-default pull-left emailResend", 3664 IconCssClass = "fa-envelope", 3665 Attributes = new Dictionary<string, string> 3666 { 3667 {"data-resend-href", resendOrder} 3668 } 3669 }) 3670 } 3671 @if (!isCheckoutFlow) 3672 { 3673 @RenderBootstrapButton(new BootstrapButtonSettings 3674 { 3675 Label = Translate("Back"), 3676 Href = "javascript:history.back();", 3677 CssClass = "btn-bg2 pull-right", 3678 IconCssClass = "fa-arrow-left" 3679 }) 3680 } 3681 3682 </div> 3683 } 3684 @helper RenderCartContentsCustom(List<LoopItem> orderlines, CartOutputType outputType = CartOutputType.ReadOnly) 3685 { 3686 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 3687 var ulCssClass = outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart ? "cartProductsList" : "col-xs-12"; 3688 var ulCssId = outputType == CartOutputType.MiniCart ? "miniCartContainer" : ""; 3689 var isB2BRetailPrices = isB2B && (HttpContext.Current.Request.Cookies["isRetailPrice"]?.Value ?? "false").Equals("true") && (outputType == CartOutputType.Editable || outputType == CartOutputType.MiniCart); 3690 var unitPriceLabel = Translate("Unit price"); 3691 var hideSubTotal = isB2BRetailPrices ? "hidden" : ""; 3692 var headerUnitPrice = isB2B && !isB2BRetailPrices ? Translate("Dealer price") : unitPriceLabel; 3693 3694 if (outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart && orderlines.Any()) 3695 { 3696 <div class="showCartHeader col-sm-12 noPadding"> 3697 <div class="hidden-xs col-sm-2 col-xs-offset-6 noPadding mdAlignRight">@headerUnitPrice</div> 3698 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty")</div> 3699 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 3700 </div> 3701 } 3702 else if (outputType == CartOutputType.MiniCart) 3703 { 3704 var totalQty = GetInteger("Ecom:Order.OrderLines.TotalProductQuantity"); // variable needed to avoid Ajax issues with the attribute value 3705 3706 // This will allow carts to be picked up by "Abandoned Carts" provider without users going to the cart 3707 if (Dynamicweb.Ecommerce.Common.Context.Cart != null && (User.IsExtranetUserLoggedIn() && GetString("Ecom:Order.Customer.Email").IsNullOrEmpty() || GetString("Ecom:Order.ShopID").IsNullOrEmpty())) 3708 { 3709 var userEmail = Pageview.User != null ? Pageview.User.Email : string.Empty; 3710 if (userEmail.IsNotNullOrEmpty()) 3711 { 3712 Dynamicweb.Ecommerce.Common.Context.Cart.CustomerEmail = userEmail; 3713 } 3714 @* 3715 TODO Fix code below because it's rendering an error in the Contacts Pop-up 3716 Dynamicweb.Ecommerce.Common.Context.Cart.ShopId = Pageview.Area.EcomShopId; 3717 Dynamicweb.Ecommerce.Common.Context.Cart.Save(); 3718 *@ 3719 } 3720 3721 @:<div> 3722 var orderMinicart = Dynamicweb.Ecommerce.Common.Context.Cart; 3723 var lastDateMinicart = (DateTime?) null; 3724 3725 if (orderMinicart != null) 3726 { 3727 var lineModifedMinicart = orderMinicart.OrderLines.Max(x => x.Modified); // Gets the latest changed date on the line, requires at least one line to be present 3728 lastDateMinicart = lineModifedMinicart > orderMinicart.Modified ? lineModifedMinicart : orderMinicart.Modified; 3729 } 3730 @:<div id="miniCart" data-quantity="@totalQty" data-orderId='@GetString("Ecom:Order.ID")' data-modifiedDate="@lastDateMinicart"> 3731 } 3732 3733 @:<ul class="@ulCssClass" id="@ulCssId"> 3734 3735 foreach (var orderline in orderlines) 3736 { 3737 if (orderline.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Discount && orderline.GetInteger("Ecom:Order:OrderLine.Type") != (int) OrderLineType.Tax) 3738 { 3739 if (outputType == CartOutputType.Email) 3740 { 3741 @InternalRenderEmailCartContentLineCustom(orderline) 3742 } 3743 else 3744 { 3745 @InternalRenderCartContentLineCustom(orderline, outputType) 3746 } 3747 } 3748 } 3749 if (outputType != CartOutputType.Email) 3750 { 3751 @:</ul> 3752 } 3753 if (outputType == CartOutputType.MiniCart) 3754 { 3755 var myCartPageUrl = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("MyCart")); 3756 var orderDiscount = orderlines 3757 .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()) 3758 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 3759 3760 <footer class="col-xs-12"> 3761 @if (orderDiscount < 0) 3762 { 3763 <div class="col-xs-12 noPadding"> 3764 @Translate("Discount") <span class="pull-right">@RenderProductPrice(Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true))</span> 3765 </div> 3766 } 3767 <div class="subTotal col-xs-12 noPadding @hideSubTotal"> 3768 *@Translate("Subtotal") <span class="pull-right">@RenderProductPrice(GetString("Ecom:Order.OrderLines.Total.Price"))</span> 3769 </div> 3770 <div class="miniCartBtns col-xs-12 noPadding"> 3771 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Show Cart"), string.Concat(myCartPageUrl, "?CartV2.GotoStep0=true"), "btn-default pull-left")) 3772 3773 @{ 3774 var isWebServiceConnectionAvailable = Dna.Ecommerce.LiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 3775 3776 if ((isWebServiceConnectionAvailable || !ShowNoErpConnectionMessage())) 3777 { 3778 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Checkout"), string.Concat(myCartPageUrl, "?CartV2.GotoStep1=true"), "btn-default pull-right")) 3779 } 3780 } 3781 </div> 3782 3783 @InternalRenderOrderAmountsDisclaimerCustom(orderlines, isB2B) 3784 </footer> 3785 @:</div> 3786 @:</div> 3787 @:</div> 3788 } 3789 } 3790 @helper RenderCartContentsCustom(Order order, OrderLineCollection orderlines, CartOutputType outputType = CartOutputType.ReadOnly) 3791 { 3792 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 3793 var ulCssClass = outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart ? "cartProductsList" : "col-xs-12"; 3794 var ulCssId = outputType == CartOutputType.MiniCart ? "miniCartContainer" : ""; 3795 var headerUnitPrice = isB2B ? Translate("Dealer price") : Translate("Unit price"); 3796 3797 if (outputType != CartOutputType.Email && outputType != CartOutputType.MiniCart && orderlines.Any()) 3798 { 3799 <div class="showCartHeader col-sm-12 noPadding"> 3800 <div class="hidden-xs col-sm-2 col-xs-offset-6 noPadding mdAlignRight">@headerUnitPrice</div> 3801 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty")</div> 3802 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 3803 </div> 3804 } 3805 3806 @:<ul class="@ulCssClass" id="@ulCssId"> 3807 3808 foreach (var orderline in orderlines) 3809 { 3810 if (orderline.OrderLineType != OrderLineType.Discount && orderline.OrderLineType != OrderLineType.Tax) 3811 { 3812 @InternalRenderCartContentLineCustom(order, orderline, outputType) 3813 } 3814 } 3815 if (outputType != CartOutputType.Email) 3816 { 3817 @:</ul> 3818 } 3819 } 3820 @helper InternalRenderCartContentLineCustom(LoopItem orderline, CartOutputType outputType) 3821 { 3822 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 3823 var productStock = 999999; 3824 var productAvailableAmount = 999999; 3825 var productQuantity = orderline.GetInteger("Ecom:Order:OrderLine.Quantity"); 3826 var productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 3827 var variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 3828 var productName = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 3829 var productNumber = orderline.GetString("Ecom:Order:OrderLine.ProductNumber"); 3830 var productImage = Dna.Hewitt.Images.GetHewittImagePath(orderline); 3831 var imageUrl = Images.GetImage(productImage, 95, 95); 3832 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 3833 var isDiscountOrderline = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount") || orderline.GetString("Ecom:Order:OrderLine.ParentLineID").IsNotNullOrEmpty(); 3834 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)); 3835 var figureClass = outputType == CartOutputType.MiniCart ? "text-center col-xs-3 noPadding" : "text-center col-xs-4"; 3836 var prodContainerClass = outputType == CartOutputType.MiniCart ? "col-xs-9 noPaddingRight" : "col-xs-8 prodName noPadding"; 3837 prodContainerClass = string.Concat(prodContainerClass, isDiscountOrderline ? outputType == CartOutputType.MiniCart ? " col-xs-offset-3" : " col-xs-offset-4" : string.Empty); 3838 var productFriendlyUrl = string.Concat(Helpers.GetCurrentUrl(true), productUrl); 3839 var shareFacebookUrl = string.Concat("https://www.facebook.com/sharer/sharer.php?u=",productFriendlyUrl); 3840 var shareTwitterUrl = string.Concat("https://twitter.com/home?status=", productFriendlyUrl); 3841 var headerUnitPrice = isB2B ? Translate("Dealer price:") : Translate("Unit price"); 3842 var isB2BRetailPrices = isB2B && (HttpContext.Current.Request.Cookies["isRetailPrice"]?.Value ?? "false").Equals("true") && (outputType == CartOutputType.Editable || outputType == CartOutputType.MiniCart); 3843 var isPdfRequest = Sanitize.Parameter("pdf").IsNotNullOrEmpty(); 3844 var imageSettings = new ImageSettings 3845 { 3846 Source = imageUrl, 3847 AltText = productName, 3848 Href = productUrl, 3849 IncludeWrapper = true, 3850 WrapperElement = Sanitize.Parameter("print").IsNotNullOrEmpty() ? "div" : "figure", 3851 WrapperCssClass = figureClass 3852 }; 3853 var orderlineId = orderline.GetString("Ecom:Order:OrderLine.Id"); 3854 var liClass = string.Concat("col-xs-12 col-sm-", outputType == CartOutputType.MiniCart ? "12" : "6" , " noPaddingLeft noPadding-xs"); 3855 var h2Class = outputType == CartOutputType.MiniCart && isDiscountOrderline && productId.IsNullOrEmpty() ? "col-xs-9 noPadding" : ""; 3856 <li class="col-xs-12 noPadding" data-facebook="@shareFacebookUrl" data-twitter="@shareTwitterUrl" data-isdiscount="@isDiscountOrderline"> 3857 <div class="@liClass"> 3858 @if (!isDiscountOrderline) 3859 { 3860 @RenderImage(imageSettings) 3861 } 3862 3863 <div class="@prodContainerClass"> 3864 <h2 class="@h2Class"> 3865 @if (isDiscountOrderline) 3866 { 3867 <strong>@productName</strong> 3868 } 3869 else 3870 { 3871 <a href="@productUrl"> 3872 <strong>@productName</strong> 3873 @if (variantText.IsNotNullOrEmpty()) 3874 { 3875 <br/> 3876 <small>@variantText</small> 3877 } 3878 </a> 3879 } 3880 </h2> 3881 @if (outputType == CartOutputType.MiniCart) 3882 { 3883 if (isDiscountOrderline && productId.IsNullOrEmpty()) 3884 { 3885 <span class="col-xs-3 noPadding text-right">@RenderProductPrice(orderline.GetString("Ecom:Order:OrderLine.TotalPrice"))</span> 3886 } 3887 else 3888 { 3889 <span class="col-xs-12 noPadding"> 3890 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 3891 { 3892 <strong>@Translate("Qty"): </strong> 3893 @orderline.GetString("Ecom:Order:OrderLine.Quantity") 3894 } 3895 <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> 3896 </span> 3897 } 3898 } 3899 else if (productNumber.IsNotNullOrEmpty() && outputType != CartOutputType.MiniCart) 3900 { 3901 <div class="itemDetails"> 3902 @Translate("Item number"): @productNumber 3903 </div> 3904 } 3905 @if (outputType != CartOutputType.MiniCart) 3906 { 3907 foreach (LoopItem item in orderline.GetLoop("Order.OrderLineFields").Where(of => of.GetString("Ecom:Order:OrderLine.OrderLineField.Name").Equals("Note", StringComparison.InvariantCultureIgnoreCase))) 3908 { 3909 3910 var orderlinefieldName = item.GetString("Ecom:Order:OrderLine.OrderLineField.Name"); 3911 var orderlinefieldValue = item.GetString("Ecom:Order:OrderLine.OrderLineField.Value"); 3912 3913 <div class="orderlineNote"> 3914 @if (!orderlinefieldValue.IsNotNullOrEmpty() && !isPdfRequest) 3915 { 3916 <div> 3917 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Add Note")</a> 3918 </div> 3919 } 3920 else if (orderlinefieldValue.IsNotNullOrEmpty()) 3921 { 3922 <div> 3923 <strong>@orderlinefieldName:</strong> @orderlinefieldValue<br/> 3924 </div> 3925 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Edit Note")</a> 3926 } 3927 </div> 3928 if (outputType == CartOutputType.Editable) 3929 { 3930 <div style="display: none"> 3931 <div id="edit-note@(orderlineId)" style="width: 460px;"> 3932 <form class="cartChange" method="POST" action="@SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> 3933 <h2>@Translate("Product Note")</h2> 3934 @orderlinefieldName:<br/> 3935 @RenderField(new FieldSettings 3936 { 3937 Type = FieldType.Text, 3938 SystemName = item.GetString("Ecom:Order:OrderLine.OrderLineField.InputTextField.Name"), 3939 Value = item.GetString("Ecom:Order:OrderLine.OrderLineField.Value"), 3940 Attributes = new Dictionary<string, string> 3941 { 3942 {"maxlength", "80"}, 3943 {"data-errorMessage", Translate("Please limit your Notes to a maximum of 80 characters")} 3944 } 3945 }) <br/> 3946 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"), "btn btn-bg"))<br/> 3947 </form> 3948 </div> 3949 </div> 3950 } 3951 } 3952 } 3953 </div> 3954 3955 </div> 3956 3957 @if (outputType != CartOutputType.MiniCart) 3958 { 3959 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 3960 var tempCssClass = !isDiscountOrderline ? "noPadding" : string.Empty; 3961 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"); 3962 var priceRaw = isB2BRetailPrices ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.GetDouble("Ecom:Product.DBPrice")) : orderline.GetString("Ecom:Order:OrderLine.UnitPrice"); 3963 if (isDiscountOrderline) 3964 { 3965 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight">&nbsp;</div> 3966 } 3967 else 3968 { 3969 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight"> 3970 @if (orderLineType == OrderLineType.PointProduct) 3971 { 3972 @:@orderline.GetString("Ecom:Order:OrderLine.UnitPoints")&nbsp;@Translate(orderline.GetString("Ecom:Order:OrderLine.UnitPoints") == "1" ? "point" : "points") 3973 } 3974 else if (isB2B && orderline.GetDouble("Ecom:Product.DBPrice") > 0 && !orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price").Equals(orderline.GetDouble("Ecom:Product.DBPrice")) && !isB2BRetailPrices) 3975 { 3976 <strong class="hidden-sm hidden-md hidden-lg pull-left">@headerUnitPrice</strong> 3977 <del>@Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.GetDouble("Ecom:Product.DBPrice"))</del><br/> 3978 <span>@orderline.GetString("Ecom:Order:OrderLine.UnitPrice")</span> 3979 } 3980 else 3981 { 3982 @priceRaw 3983 } 3984 </div> 3985 } 3986 3987 <div class="col-xs-6 col-xs-offset-4 col-sm-offset-0 col-sm-2 quantity noPaddingLeft mdAlignRight"> 3988 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 3989 { 3990 <strong class="hidden-sm hidden-md hidden-lg pull-left">@Translate("Qty")&nbsp;&nbsp;</strong> 3991 if (outputType != CartOutputType.Editable || orderLineType == OrderLineType.Discount || orderLineType == OrderLineType.ProductDiscount || orderLineType == OrderLineType.GiftCard || orderline.GetInteger("Ecom:Product.Type") == 1) 3992 { 3993 <span>@productQuantity</span> 3994 } 3995 else 3996 { 3997 <form class="cartChange" method="POST" action="@SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> 3998 @InternalRenderQuantityField(productStock, productAvailableAmount, productQuantity, orderline.GetString("Ecom:Order:OrderLine.Quantity.Input.Name"), 10, true, variantText.IsNotNullOrEmpty()) 3999 </form> 4000 } 4001 } 4002 </div> 4003 4004 <div class="col-xs-12 col-sm-2 totalPrice text-right noPadding-xs mdAlignRight @tempCssClass"> 4005 @totalPrice 4006 @if (outputType == CartOutputType.Editable && !isDiscountOrderline) 4007 { 4008 <a class="removeFromCart" href="@orderline.GetString("Ecom:Order:OrderLine.DeleteLink")"> 4009 @RenderIcon("fa-times") 4010 </a> 4011 } 4012 </div> 4013 } 4014 </li> 4015 } 4016 @helper InternalRenderCartContentLineCustom(Order order, OrderLine orderline, CartOutputType outputType) 4017 { 4018 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 4019 var productStock = 999999; 4020 var productAvailableAmount = 999999; 4021 var productQuantity = Converter.ToInt32(orderline.Quantity); 4022 var productId = orderline.ProductId; 4023 var variantId = orderline.ProductVariantId; 4024 var productName = orderline.ProductName; 4025 var productNumber = orderline.ProductNumber; 4026 var productImage = orderline.ProductId.IsNotNullOrEmpty() ? Dna.Hewitt.Images.GetHewittImagePath(orderline) : string.Empty; 4027 productImage = productImage.StartsWith("/Files", StringComparison.InvariantCultureIgnoreCase) ? productImage : string.Concat("/Files", productImage); 4028 var imageUrl = Images.GetImage(productImage, 95, 95); 4029 var variantText = orderline.ProductVariantText; 4030 var isDiscountOrderline = orderline.DiscountId.IsNotNullOrEmpty() || orderline.OrderLineType == OrderLineType.Discount || orderline.ParentLineId.IsNotNullOrEmpty(); 4031 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)); 4032 var figureClass = outputType == CartOutputType.MiniCart ? "text-center col-xs-3 noPadding" : "text-center col-xs-4"; 4033 var prodContainerClass = outputType == CartOutputType.MiniCart ? "col-xs-9 noPaddingRight" : "col-xs-8 prodName noPadding"; 4034 prodContainerClass = string.Concat(prodContainerClass, isDiscountOrderline ? outputType == CartOutputType.MiniCart ? " col-xs-offset-3" : " col-xs-offset-4" : string.Empty); 4035 var productFriendlyUrl = string.Concat(Helpers.GetCurrentUrl(true), productUrl); 4036 var shareFacebookUrl = string.Concat("https://www.facebook.com/sharer/sharer.php?u=",productFriendlyUrl); 4037 var shareTwitterUrl = string.Concat("https://twitter.com/home?status=", productFriendlyUrl); 4038 var headerUnitPrice = isB2B ? Translate("Dealer price:") : Translate("Unit price"); 4039 var isPdfRequest = Sanitize.Parameter("pdf").IsNotNullOrEmpty(); 4040 var imageSettings = new ImageSettings 4041 { 4042 Source = imageUrl, 4043 AltText = productName, 4044 Href = productUrl, 4045 IncludeWrapper = true, 4046 WrapperElement = Sanitize.Parameter("print").IsNotNullOrEmpty() ? "div" : "figure", 4047 WrapperCssClass = figureClass 4048 }; 4049 var orderlineId = orderline.Id; 4050 var liClass = string.Concat("col-xs-12 col-sm-", outputType == CartOutputType.MiniCart ? "12" : "6" , " noPaddingLeft noPadding-xs"); 4051 var h2Class = outputType == CartOutputType.MiniCart && isDiscountOrderline && productId.IsNullOrEmpty() ? "col-xs-9 noPadding" : ""; 4052 <li class="col-xs-12 noPadding" data-facebook="@shareFacebookUrl" data-twitter="@shareTwitterUrl" data-isdiscount="@isDiscountOrderline"> 4053 <div class="@liClass"> 4054 @if (!isDiscountOrderline) 4055 { 4056 @RenderImage(imageSettings) 4057 } 4058 4059 <div class="@prodContainerClass"> 4060 <h2 class="@h2Class"> 4061 @if (isDiscountOrderline) 4062 { 4063 <strong>@productName</strong> 4064 } 4065 else 4066 { 4067 <a href="@productUrl"> 4068 <strong>@productName</strong> 4069 @if (variantText.IsNotNullOrEmpty()) 4070 { 4071 <br/> 4072 <small>@variantText</small> 4073 } 4074 </a> 4075 } 4076 </h2> 4077 @if (outputType == CartOutputType.MiniCart) 4078 { 4079 if (isDiscountOrderline && productId.IsNullOrEmpty()) 4080 { 4081 <span class="col-xs-3 noPadding text-right">@RenderProductPrice(orderline.Price.PriceFormatted)</span> 4082 } 4083 else 4084 { 4085 <span class="col-xs-12 noPadding"> 4086 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 4087 { 4088 <strong>@Translate("Qty"): </strong> 4089 @orderline.Quantity 4090 } 4091 <span class="pull-right">@RenderProductPrice(orderline.Price.PriceFormatted)</span> 4092 </span> 4093 } 4094 } 4095 else if (productNumber.IsNotNullOrEmpty() && outputType != CartOutputType.MiniCart) 4096 { 4097 <div class="itemDetails"> 4098 @Translate("Item number"): @productNumber 4099 </div> 4100 } 4101 @if (outputType != CartOutputType.MiniCart) 4102 { 4103 var noteField = orderline.get_OrderLineFieldValue("Note"); 4104 4105 if(noteField != null) 4106 { 4107 4108 var orderlinefield = noteField.OrderLineFieldSystemName; 4109 var orderlinefieldName = noteField.OrderLineFieldName; 4110 var orderlinefieldValue = noteField.Value; 4111 4112 <div class="orderlineNote"> 4113 @if (!orderlinefieldValue.IsNotNullOrEmpty() && !isPdfRequest) 4114 { 4115 <div> 4116 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Add Note")</a> 4117 </div> 4118 } 4119 else if (orderlinefieldValue.IsNotNullOrEmpty()) 4120 { 4121 <div> 4122 <strong>@orderlinefieldName:</strong> @orderlinefieldValue<br/> 4123 </div> 4124 <a href="#edit-note@(orderlineId)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Edit Note")</a> 4125 } 4126 </div> 4127 if (outputType == CartOutputType.Editable) 4128 { 4129 <div style="display: none"> 4130 <div id="edit-note@(orderlineId)" style="width: 460px;"> 4131 <form class="cartChange" method="POST" action="@SearchEngineFriendlyURLs.GetFriendlyUrl(Pageview.Page.ID)"> 4132 <h2>@Translate("Product Note")</h2> 4133 @orderlinefieldName:<br/> 4134 @orderlinefield <br/> 4135 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"), "btn btn-bg"))<br/> 4136 </form> 4137 </div> 4138 </div> 4139 } 4140 } 4141 } 4142 </div> 4143 4144 </div> 4145 4146 @if (outputType != CartOutputType.MiniCart) 4147 { 4148 var orderLineType = orderline.OrderLineType; 4149 var tempCssClass = !isDiscountOrderline ? "noPadding" : string.Empty; 4150 if (isDiscountOrderline) 4151 { 4152 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight">&nbsp;</div> 4153 } 4154 else 4155 { 4156 <div class="col-xs-8 col-xs-offset-4 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight"> 4157 @if (orderLineType == OrderLineType.PointProduct) 4158 { 4159 var orderlinePoints = orderline.UnitPoints ?? 0D; 4160 @:@orderlinePoints&nbsp;@Translate(orderlinePoints == 1 ? "point" : "points") 4161 } 4162 else if (isB2B && orderline.Product.DefaultPrice > 0 && !orderline.UnitPrice.Price.Equals(orderline.Product.DefaultPrice)) 4163 { 4164 <strong class="hidden-sm hidden-md hidden-lg pull-left">@headerUnitPrice</strong> 4165 <del>@Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderline.Product.DefaultPrice)</del><br/> 4166 <span>@orderline.UnitPrice.PriceFormatted</span> 4167 } 4168 else 4169 { 4170 @orderline.UnitPrice.PriceFormatted 4171 } 4172 </div> 4173 } 4174 4175 <div class="col-xs-6 col-xs-offset-4 col-sm-offset-0 col-sm-2 quantity noPaddingLeft mdAlignRight"> 4176 @if (!isDiscountOrderline || (isDiscountOrderline && productId.IsNotNullOrEmpty())) 4177 { 4178 <strong class="hidden-sm hidden-md hidden-lg pull-left">@Translate("Qty")&nbsp;&nbsp;</strong> 4179 if (outputType != CartOutputType.Editable || orderLineType == OrderLineType.Discount || orderLineType == OrderLineType.ProductDiscount || orderLineType == OrderLineType.GiftCard || orderline.Product.Type == Dynamicweb.Ecommerce.Products.ProductType.Service) 4180 { 4181 <span>@productQuantity</span> 4182 } 4183 } 4184 </div> 4185 4186 <div class="col-xs-12 col-sm-2 totalPrice text-right noPadding-xs mdAlignRight @tempCssClass"> 4187 @orderline.Price.PriceFormatted 4188 </div> 4189 } 4190 </li> 4191 } 4192 @helper InternalRenderEmailCartContentLineCustom(LoopItem orderline) 4193 { 4194 var orderLineType = (OrderLineType) orderline.GetInteger("Ecom:Order:OrderLine.Type"); 4195 var domain = GetWebsiteDomain(Pageview); 4196 var productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 4197 var variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 4198 var productName = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 4199 var productNumber = orderline.GetString("Ecom:Product.Number"); 4200 var productImage = Dna.Hewitt.Images.GetHewittImagePath(orderline); 4201 productImage = productImage.IsNotNullOrEmpty() ? productImage : Pageview.Area.Item["NoImage"].ToString(); 4202 var imageUrl = domain + "/" + Images.GetImage(productImage, 95, 123) + "?Skip404=true"; 4203 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 4204 var isDiscountOrderline = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount") || orderline.GetString("Ecom:Order:OrderLine.ParentLineID").IsNotNullOrEmpty(); 4205 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); 4206 productUrl = domain + SearchEngineFriendlyURLs.GetFriendlyUrl(productUrl); 4207 var headerUnitPrice = Dna.Hewitt.Helpers.IsUserB2B() ? Translate("Dealer price") : Translate("Unit price"); 4208 4209 @RenderTableRowSpacer(isDiscountOrderline ? 5 : 10, 3) 4210 4211 <tr> 4212 <td> 4213 <figure align="left"> 4214 @if (isDiscountOrderline) 4215 { 4216 <text>&nbsp;</text> 4217 } 4218 else 4219 { 4220 <a target="_blank" href="@productUrl"> 4221 <img alt="@productName" title="@productName" src="@imageUrl" width="95"/> 4222 </a> 4223 } 4224 </figure> 4225 </td> 4226 <td valign="top"> 4227 @if (isDiscountOrderline) 4228 { 4229 <strong>@productName</strong> 4230 if (variantText.IsNotNullOrEmpty() || productNumber.IsNotNullOrEmpty()) 4231 { 4232 <br/> 4233 } 4234 if (variantText.IsNotNullOrEmpty()) 4235 { 4236 @variantText 4237 if (productNumber.IsNotNullOrEmpty()) 4238 { 4239 <text> - </text> 4240 } 4241 } 4242 if (productNumber.IsNotNullOrEmpty()) 4243 { 4244 <text>@Translate("Item number"): @productNumber</text> 4245 } 4246 } 4247 else 4248 { 4249 <a target="_blank" href="@productUrl"> 4250 <strong>@productName</strong> 4251 @if (variantText.IsNotNullOrEmpty() || productNumber.IsNotNullOrEmpty()) 4252 { 4253 <br/> 4254 } 4255 @if (variantText.IsNotNullOrEmpty()) 4256 { 4257 @variantText 4258 if (productNumber.IsNotNullOrEmpty()) 4259 { 4260 <text> - </text> 4261 } 4262 } 4263 @if (productNumber.IsNotNullOrEmpty()) 4264 { 4265 <text>@Translate("Item number"): @productNumber</text> 4266 } 4267 </a> 4268 } 4269 <br/> 4270 @if (!isDiscountOrderline) 4271 { 4272 if (orderLineType == OrderLineType.PointProduct) 4273 { 4274 @:<strong>@orderline.GetString("Ecom:Order:OrderLine.UnitPoints")&nbsp;@Translate(orderline.GetString("Ecom:Order:OrderLine.UnitPoints") == "1" ? "point" : "points")</strong> 4275 } 4276 else 4277 { 4278 <strong>@headerUnitPrice</strong> 4279 @orderline.GetString("Ecom:Order:OrderLine.UnitPrice") 4280 } 4281 4282 <br/> 4283 <strong>@Translate("Quantity")</strong> 4284 @orderline.GetString("Ecom:Order:OrderLine.Quantity") 4285 <br/> 4286 foreach (LoopItem item in orderline.GetLoop("Order.OrderLineFields")) 4287 { 4288 var orderlinefieldName = item.GetString("Ecom:Order:OrderLine.OrderLineField.Name"); 4289 var orderlinefieldValue = item.GetString("Ecom:Order:OrderLine.OrderLineField.Value"); 4290 <div class="orderlineNote"> 4291 @if (orderlinefieldValue.IsNotNullOrEmpty() && orderlinefieldName == "Note") 4292 { 4293 <div> 4294 <strong>@orderlinefieldName:</strong> @orderlinefieldValue<br/> 4295 </div> 4296 } 4297 </div> 4298 } 4299 } 4300 else if(productId.IsNotNullOrEmpty()) 4301 { 4302 <strong>@Translate("Quantity")</strong> 4303 @orderline.GetString("Ecom:Order:OrderLine.Quantity") 4304 } 4305 </td> 4306 <td class="noPadding" valign="top" style="text-align: right; padding-right: 90px"> 4307 <strong>@orderline.GetString("Ecom:Order:OrderLine.TotalPrice")</strong> 4308 </td> 4309 </tr> 4310 <tr> 4311 <td style="border-bottom: 1px solid @GetPalletColorNumber(1) text-align:left" colspan="3" height="10"></td> 4312 </tr> 4313 } 4314 @helper RenderOrderEmailButton(string href, string text, Dictionary<string, string> options = null) 4315 { 4316 if (href.IsNotNullOrEmpty() && text.IsNotNullOrEmpty()) 4317 { 4318 var width = options != null && options.ContainsKey("width") ? options["width"] : "120px"; 4319 var height = options != null && options.ContainsKey("height") ? options["height"] : "36px"; 4320 var background = options != null && options.ContainsKey("background") ? options["background"] : "#13315f"; 4321 var border = options != null && options.ContainsKey("border") ? options["border"] : "1px solid ffffff"; 4322 var color = options != null && options.ContainsKey("color") ? options["color"] : "#ffffff"; 4323 var fontFamily = options != null && options.ContainsKey("font-family") ? options["font-family"] : "Helvetica, Arial, sans-serif"; 4324 var fontSize = options != null && options.ContainsKey("font-size") ? options["font-size"] : "14px"; 4325 var fontStyle = options != null && options.ContainsKey("font-style") ? options["font-style"] : "normal"; 4326 var textAlign = options != null && options.ContainsKey("text-align") ? options["text-align"] : "center"; 4327 var textDecoration = options != null && options.ContainsKey("text-decoration") ? options["text-decoration"] : "none"; 4328 4329 var rect = "style=\"width:" + width + ";height:" + height + ";border:" + border + ";color:" + color + ";v-text-anchor:middle; \" fillcolor=\"" + background + "\""; 4330 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 + ";"; 4331 4332 <div> 4333 <!--[if mso]> 4334 <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="@href" @rect> 4335 <w:anchorlock/> 4336 <center> 4337 <![endif]--> 4338 <a class="mobile-button" target="_blank" href="@href" style="-webkit-text-size-adjust: none; display: inline-block; @anchor">@text</a> 4339 <!--[if mso]> 4340 </center> 4341 </v:rect> 4342 <![endif]--> 4343 </div> 4344 } 4345 } 4346 @helper RenderCheckoutActionsCustom(bool showPrevious = false, bool isStep2Or3 = false, bool isB2B = false) 4347 { 4348 <div class="continueButton col-xs-12"> 4349 @if (showPrevious) 4350 { 4351 var previousButton = "/Default.aspx?Id=" + Pageview.Page.ID + "&amp;" + GetString("CartV2.PreviousStepButtonName") + "=true"; 4352 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Previous"), previousButton, "pull-left previousButton")) 4353 } 4354 @if (User.IsExtranetUserLoggedIn() && Pageview.User.CurrentSecondaryUser != null) { 4355 4356 var secondaryUser = User.GetUserByID(Pageview.User.CurrentSecondaryUser.ID); 4357 var t = secondaryUser.CustomFieldValues.First(x => x.CustomField.SystemName == "AccessUser_DisallowOrdering").Value; 4358 4359 if (t != null) 4360 { 4361 if (isStep2Or3 && t.ToString() == "True") 4362 { 4363 4364 } 4365 else 4366 { 4367 @RenderField(FieldSettings.CreateSubmitField(Translate(isB2B ? "Place order" : "Next"), "btn-default pull-right")) 4368 } 4369 } 4370 } 4371 else { 4372 @RenderField(FieldSettings.CreateSubmitField(Translate("Next"), "btn-default pull-right")) 4373 } 4374 4375 </div> 4376 } 4377 @helper RenderCartSummaryCustom(List<LoopItem> orderlines, bool splitAddresses = true, bool showEditOrder = true) 4378 { 4379 var orderDiscount = orderlines 4380 .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()) 4381 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 4382 4383 var areAddessesTheSame = AreAddressesTheSame(); 4384 4385 var shippingSurcharge = GetDouble("ShippingFeeSurchargePortion.Clean"); 4386 var shippingMethodPrice = GetDouble("Ecom:Order.ShippingFee.Price"); 4387 var shippingMethodPriceFormatted = GetString("Ecom:Order.ShippingFee.PriceWithoutVATFormatted"); 4388 4389 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 4390 { 4391 shippingMethodPrice -= shippingSurcharge; 4392 shippingMethodPriceFormatted = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice); 4393 } 4394 4395 <h2 data-cartid="@GetString("Ecom:Order.ID")">@Translate("Order Summary")</h2> 4396 4397 if (orderlines.Any()) 4398 { 4399 var billingAndShippingAddressesTranslate = Translate("Billing & Shipping Address"); 4400 var billingAddressTranslate = Translate("Billing Address"); 4401 var shippingAddressTranslate = Translate("Shipping Address"); 4402 4403 <dl data-billingandshippingaddresses='@billingAndShippingAddressesTranslate' data-billingaddress='@billingAddressTranslate' data-shippingaddress='@shippingAddressTranslate'> 4404 @if(GetString("Ecom:Order.Customer.Name").IsNotNullOrEmpty()) { 4405 <dt class="col-xs-12 rightTitle borderBottom shippingAddressTitle"> 4406 @shippingAddressTranslate 4407 </dt> 4408 <dd class="col-xs-12 shippingAddress"> 4409 @if(GetString("Ecom:Order.Delivery.Name").IsNotNullOrEmpty()) 4410 { 4411 @GetString("Ecom:Order.Delivery.Name")<br/> 4412 } 4413 @GetAddressFormatted(AddressSource.EcomDelivery, false, true, true, "<br/>") 4414 </dd> 4415 if (splitAddresses) 4416 { 4417 <dt class="col-xs-12 rightTitle billingAddressTitle"> 4418 @billingAddressTranslate 4419 </dt> 4420 <dd class="col-xs-12 billingAddress"> 4421 @GetString("Ecom:Order.Customer.Name")<br/> 4422 @GetAddressFormatted(AddressSource.EcomCustomer, false, true, true, "<br/>") 4423 </dd> 4424 } 4425 } 4426 4427 @InternalRenderCartSummaryLine(Translate("Payment Method"), GetString("Ecom:Order.PaymentMethod"), string.Empty, "paymentMethodName", false, true) 4428 4429 <dt class="col-xs-12 borderBottom orderSummaryDeta">@Translate("Items")</dt> 4430 <dd class="col-xs-12 osProducts"> 4431 <ul> 4432 @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)) 4433 { 4434 var variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 4435 var isDiscountOrderline = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount") || orderline.GetString("Ecom:Order:OrderLine.ParentLineID").IsNotNullOrEmpty(); 4436 4437 <li class="col-xs-12 noPadding" data-isdiscount="@isDiscountOrderline"> 4438 <div class="col-xs-12 noPaddingLeft"> 4439 @orderline.GetString("Ecom:Order:OrderLine.ProductName") 4440 @if (variantText.IsNotNullOrEmpty()) 4441 { 4442 <br/> 4443 <small>@variantText</small> 4444 } 4445 </div> 4446 <div> 4447 <small class="col-xs-8 noPaddingLeft">@Translate("Qty"): @orderline.GetString("Ecom:Order:OrderLine.Quantity")</small> 4448 <span class="col-xs-4 text-right noPadding">@orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceWithoutVATFormatted")</span> 4449 </div> 4450 </li> 4451 } 4452 </ul> 4453 </dd> 4454 4455 @if (GetDouble("Ecom:Order.TotalPoints") > 0) 4456 { 4457 @InternalRenderCartSummaryLine(Translate("Loyalty Points Spent"), GetString("Ecom:Order.TotalPoints"), "orderSummaryPointsSpent") 4458 } 4459 4460 @if (GetDouble("Ecom:Order.RewardTotalPoints") > 0) 4461 { 4462 @InternalRenderCartSummaryLine(Translate("Loyalty Points Earned"), GetString("Ecom:Order.RewardTotalPoints"), "orderSummaryPointsEarned") 4463 } 4464 4465 @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) 4466 4467 @if (orderDiscount < 0) 4468 { 4469 @InternalRenderCartSummaryLine(Translate("Discount"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true), "orderSummaryOrderSavings") 4470 } 4471 4472 @InternalRenderCartSummaryLine(GetString("Ecom:Order.ShippingMethod").IsNotNullOrEmpty() ? GetString("Ecom:Order.ShippingMethod") : GetString("Ecom:Order.ShippingMethodID"), shippingMethodPrice > 0 ? shippingMethodPriceFormatted : "&nbsp;", "orderSummaryShippingName", "orderSummaryShippingPrice", false, true) 4473 4474 @InternalRenderCartSummaryLine(Translate("Taxes"), GetDouble("Ecom:Order.Taxes.Total.Price") > 0 ? GetString("Ecom:Order.Taxes.Total") : "", "orderSummaryTaxes", "orderSummaryTotalTaxes", false, true) 4475 @InternalRenderCartSummaryLine(Translate("Shipping Surcharge"), (shippingSurcharge > 0 ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingSurcharge) : ""), "orderSurcharge", "orderSurchargeTotal", false, true) 4476 @InternalRenderCartSummaryLine(Translate("Total"), GetString("Ecom:Order.OrderLines.Total.PriceWithoutVAT"), "orderSummaryTotalLabel", "orderSummaryTotal", true) 4477 </dl> 4478 4479 @InternalRenderOrderAmountsDisclaimerCustom(orderlines, Dna.Hewitt.Helpers.IsUserB2B()) 4480 4481 if (showEditOrder) 4482 { 4483 <div id="editOrderButton" class="col-xs-12 text-center"> 4484 @RenderBootstrapButton(BootstrapButtonSettings.CreateButton(Translate("Edit order"), string.Concat(SearchEngineFriendlyURLs.GetFriendlyUrl(Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "MyCart").ID), "?CartV2.GotoStep0=true"), "btn-outline")) 4485 </div> 4486 } 4487 } 4488 } 4489 4490 @helper RenderCartContentsSummaryCustom(List<LoopItem> orderlines, string voucherValue, CartOutputType outputType = CartOutputType.ReadOnly) 4491 { 4492 @RenderCartContentsSummaryCustom(orderlines, voucherValue, PromoCodeChecker.CheckOrderPromoCode(voucherValue), outputType) 4493 } 4494 4495 @helper RenderCartContentsSummaryCustom(List<LoopItem> orderlines, string voucherValue, PromoCodeInfo voucherResult, CartOutputType outputType = CartOutputType.ReadOnly) 4496 { 4497 var orderDiscount = orderlines 4498 .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()) 4499 .Sum(s => s.GetDouble("Ecom:Order:OrderLine.Price.Price")); 4500 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 4501 var myCartPage = Pageview.Page.ID == GetPageIdByNavigationTag("MyCart"); 4502 var isB2BRetailPrices = isB2B && (HttpContext.Current.Request.Cookies["isRetailPrice"]?.Value ?? "false").Equals("true") && myCartPage; 4503 4504 if (outputType != CartOutputType.Email && !isB2BRetailPrices) 4505 { 4506 @:<div id="totalPriceContainer" class="col-xs-12 col-sm-5 noPadding pull-right noPadding-xs"> 4507 } 4508 4509 if (voucherResult.Valid && !voucherResult.Expired && !voucherResult.Inactive && voucherValue.IsNotNullOrEmpty()) 4510 { 4511 <div class="col-xs-12 noPadding"> 4512 <div class="discountContainer col-xs-12"> 4513 <div class="row"> 4514 <span class="col-xs-8 col-sm-7 noPadding">@Translate("Voucher"): @EcommerceHelpers.GetVoucherName(voucherValue)</span> 4515 </div> 4516 </div> 4517 </div> 4518 } 4519 4520 if (GetDouble("Ecom:Order.TotalPoints") > 0) 4521 { 4522 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Spent"), GetString("Ecom:Order.TotalPoints"), false, outputType) 4523 } 4524 4525 if (GetDouble("Ecom:Order.RewardTotalPoints") > 0) 4526 { 4527 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Earned"), GetString("Ecom:Order.RewardTotalPoints"), false, outputType) 4528 } 4529 if (GetString("Ecom:Order.PriceWithoutFees.PriceFormatted") != "0.00") 4530 { 4531 @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") 4532 } 4533 4534 if (orderDiscount < 0) 4535 { 4536 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 4537 var discount = orderDiscount < 0 ? Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, orderDiscount, true) : GetString("Ecom:Order.TotalDiscount"); 4538 @InternalRenderTotalAmountLineDiscount(voucherCode.IsNotNullOrEmpty() ? string.Concat(Translate("Coupon Code"), ": ", voucherCode) : Translate("Order Discounts"), discount, false, outputType) 4539 } 4540 if (GetString("Ecom:Order.ShippingMethodID").IsNotNullOrEmpty() || GetString("Ecom:Order.ShippingMethod").IsNotNullOrEmpty()) 4541 { 4542 var shippingSurcharge = GetDouble("ShippingFeeSurchargePortion.Clean"); 4543 var shippingMethodPrice = GetDouble("Ecom:Order.ShippingFee.Price"); 4544 var shippingMethodPriceFormatted = GetString("Ecom:Order.ShippingFee.PriceWithoutVATFormatted"); 4545 4546 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 4547 { 4548 shippingMethodPrice -= shippingSurcharge; 4549 shippingMethodPriceFormatted = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice); 4550 } 4551 4552 @InternalRenderTotalAmountLineCustom(GetString("Ecom:Order.ShippingMethod").IsNotNullOrEmpty() ? GetString("Ecom:Order.ShippingMethod") : GetString("Ecom:Order.ShippingMethodID"), shippingMethodPrice > 0 ? shippingMethodPriceFormatted : "&nbsp;", false, outputType) 4553 4554 if (shippingSurcharge > 0) 4555 { 4556 @InternalRenderTotalAmountLineCustom(Translate("Shipping Surcharge"), Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingSurcharge), false, outputType) 4557 } 4558 } 4559 if (GetString("Ecom:Order.Taxes.Total.Price") != "0.00") 4560 { 4561 @InternalRenderTotalAmountLineCustom(Translate("Taxes"), GetString("Ecom:Order.Taxes.Total"), false, outputType) 4562 } 4563 @InternalRenderTotalAmountLineCustom(string.Concat(GetString("Ecom:Order.Completed").IsNullOrEmpty() ? "*" : string.Empty, Translate("Total")), GetString("Ecom:Order.Price"), true, outputType) 4564 4565 if (outputType != CartOutputType.Email) 4566 { 4567 if(GetString("Ecom:Order.Completed").IsNullOrEmpty()) 4568 { 4569 @InternalRenderOrderAmountsDisclaimerCustom(orderlines, Dna.Hewitt.Helpers.IsUserB2B()) 4570 } 4571 @: </div> 4572 } 4573 } 4574 4575 @helper RenderCartContentsSummaryCustom(Order order, OrderLineCollection orderlines, string voucherValue, CartOutputType outputType = CartOutputType.ReadOnly) 4576 { 4577 @RenderCartContentsSummaryCustom(order, orderlines, voucherValue, PromoCodeChecker.CheckOrderPromoCode(voucherValue), outputType) 4578 } 4579 4580 @helper RenderCartContentsSummaryCustom(Order order, OrderLineCollection orderlines, string voucherValue, PromoCodeInfo voucherResult, CartOutputType outputType = CartOutputType.ReadOnly) 4581 { 4582 var orderDiscount = orderlines.Where(t => t.OrderLineType == OrderLineType.Discount || t.OrderLineType == OrderLineType.ProductDiscount && t.ParentLineId.IsNullOrEmpty()).Sum(s => s.Price.Price); 4583 var subtotal = orderlines.Where(x => x.OrderLineType != OrderLineType.Discount && x.OrderLineType != OrderLineType.Tax).Sum(x => x.Price.Price); 4584 var taxesTotal = orderlines.Where(x => x.OrderLineType == OrderLineType.Tax).Sum(x => x.Price.Price); 4585 4586 if (outputType != CartOutputType.Email) 4587 { 4588 @:<div id="totalPriceContainer" class="col-xs-12 col-sm-5 noPadding pull-right noPadding-xs"> 4589 } 4590 4591 if (voucherResult.Valid && !voucherResult.Expired && !voucherResult.Inactive && voucherValue.IsNotNullOrEmpty()) 4592 { 4593 <div class="col-xs-12 noPadding"> 4594 <div class="discountContainer col-xs-12"> 4595 <div class="row"> 4596 <span class="col-xs-8 col-sm-7 noPadding">@Translate("Voucher"): @EcommerceHelpers.GetVoucherName(voucherValue)</span> 4597 </div> 4598 </div> 4599 </div> 4600 } 4601 4602 if ((order.TotalPoints ?? 0) > 0) 4603 { 4604 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Spent"), order.TotalPoints.ToString(), false, outputType) 4605 } 4606 4607 if ((order.RewardTotalPoints ?? 0) > 0) 4608 { 4609 @InternalRenderTotalAmountLineCustom(Translate("Loyalty Points Earned"), order.RewardTotalPoints.ToString(), false, outputType) 4610 } 4611 if (subtotal > 0) 4612 { 4613 @InternalRenderTotalAmountLineCustom(Translate("Subtotal"), Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, subtotal, true), true, outputType, "fontSize16") 4614 } 4615 4616 if (orderDiscount < 0) 4617 { 4618 var discount = orderDiscount < 0 ? Services.Currencies.Format(order.Currency, orderDiscount, true) : order.TotalDiscount.PriceFormatted; 4619 @InternalRenderTotalAmountLineDiscount(voucherValue.IsNotNullOrEmpty() ? string.Concat(Translate("Coupon Code"), ": ", voucherValue) : Translate("Order Discounts"), discount, false, outputType) 4620 } 4621 if (order.ShippingMethodId.IsNotNullOrEmpty() || order.ShippingMethod.IsNotNullOrEmpty()) 4622 { 4623 var shippingSurcharge = Converter.ToDouble(order.OrderFieldValues.FirstOrDefault(ofv => ofv.OrderField.SystemName.Equals("ShippingFeeSurchargePortion"))?.Value ?? 0); 4624 var shippingMethodPrice = order.ShippingFee.Price; 4625 var shippingMethodPriceFormatted = order.ShippingFee.PriceWithoutVATFormatted; 4626 4627 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 4628 { 4629 shippingMethodPrice -= shippingSurcharge; 4630 shippingMethodPriceFormatted = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice); 4631 } 4632 4633 @InternalRenderTotalAmountLineCustom(order.ShippingMethod.IsNotNullOrEmpty() ? order.ShippingMethod : order.ShippingMethodId, shippingMethodPrice > 0 ? shippingMethodPriceFormatted : "&nbsp;", false, outputType) 4634 4635 if (shippingSurcharge > 0) 4636 { 4637 @InternalRenderTotalAmountLineCustom(Translate("Shipping Surcharge"), Services.Currencies.Format(order.Currency, shippingSurcharge), false, outputType) 4638 } 4639 } 4640 if (taxesTotal > 0) 4641 { 4642 @InternalRenderTotalAmountLineCustom(Translate("Taxes"), Services.Currencies.Format(order.Currency, taxesTotal), false, outputType) 4643 } 4644 @InternalRenderTotalAmountLineCustom(string.Concat(order.CompletedDate?.ToString().IsNullOrEmpty() ?? true ? "*" : string.Empty, Translate("Total")), order.Price.PriceFormatted, true, outputType) 4645 } 4646 4647 @helper InternalRenderTotalAmountLineDiscount(string label, string value, bool isBold = false, CartOutputType outputType = CartOutputType.ReadOnly) 4648 { 4649 var orderIsNotCompleted = GetString("Ecom:Order.Completed").IsNullOrEmpty(); 4650 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 4651 var valueCssClass = orderIsNotCompleted && voucherCode.IsNullOrEmpty() ? "col-xs-12" : string.Empty; 4652 if (outputType == CartOutputType.Email) 4653 { 4654 <tr align="left"> 4655 <td> 4656 @InternalRenderValue(label, isBold) 4657 </td> 4658 <td> 4659 &nbsp; 4660 </td> 4661 <td class="noPadding" style="padding-right: 90px; text-align: right;"> 4662 @InternalRenderValue(value, isBold) 4663 </td> 4664 </tr> 4665 } 4666 else 4667 { 4668 var tempCssClass = orderIsNotCompleted ? "noPaddingRight" : string.Empty; 4669 <div class="col-xs-6 col-sm-7 clearLeft"> 4670 @InternalRenderValue(label, isBold) 4671 </div> 4672 <div class="col-xs-6 col-sm-5 price pull-right noPadding-xs text-right @tempCssClass"> 4673 <span class="totalsDiscountVal @valueCssClass"> 4674 @InternalRenderValue(value, isBold) 4675 </span> 4676 @if (orderIsNotCompleted && voucherCode.IsNotNullOrEmpty()) 4677 { 4678 <a class="removeVoucher" href="javascript:void(0)"> 4679 @RenderIcon("fa-times") 4680 </a> 4681 } 4682 </div> 4683 } 4684 } 4685 4686 @helper InternalRenderTotalAmountLineDiscount(Order order, string label, string value, bool isBold = false, CartOutputType outputType = CartOutputType.ReadOnly) 4687 { 4688 var orderIsNotCompleted = order.CompletedDate?.ToString().IsNullOrEmpty() ?? true; 4689 var voucherCode = order.VoucherCode; 4690 var valueCssClass = orderIsNotCompleted && voucherCode.IsNullOrEmpty() ? "col-xs-12" : string.Empty; 4691 if (outputType == CartOutputType.Email) 4692 { 4693 <tr align="left"> 4694 <td> 4695 @InternalRenderValue(label, isBold) 4696 </td> 4697 <td> 4698 &nbsp; 4699 </td> 4700 <td class="noPadding" style="padding-right: 90px; text-align: right;"> 4701 @InternalRenderValue(value, isBold) 4702 </td> 4703 </tr> 4704 } 4705 else 4706 { 4707 var tempCssClass = orderIsNotCompleted ? "noPaddingRight" : string.Empty; 4708 <div class="col-xs-6 col-sm-7 clearLeft"> 4709 @InternalRenderValue(label, isBold) 4710 </div> 4711 <div class="col-xs-6 col-sm-5 price pull-right noPadding-xs text-right @tempCssClass"> 4712 <span class="totalsDiscountVal @valueCssClass"> 4713 @InternalRenderValue(value, isBold) 4714 </span> 4715 @if (orderIsNotCompleted && voucherCode.IsNotNullOrEmpty()) 4716 { 4717 <a class="removeVoucher" href="javascript:void(0)"> 4718 @RenderIcon("fa-times") 4719 </a> 4720 } 4721 </div> 4722 } 4723 } 4724 4725 @helper RenderVoucherFieldCustom() 4726 { 4727 var voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 4728 var voucherCodeErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderVoucherCode.ErrorMessage"); 4729 var voucherResult = PromoCodeChecker.CheckOrderPromoCode(voucherCode); 4730 var validVoucherCss = voucherResult.Valid ? "hidden" : ""; 4731 var myCart = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("MyCart")); 4732 var isCheckoutFlow = Pageview.Page.ID == GetPageIdByNavigationTag("Checkout"); 4733 var submitVoucherBtn = new BootstrapButtonSettings 4734 { 4735 Label = Translate("Apply"), 4736 Id = "applyVoucher", 4737 CssClass = "btn-default submitVoucher", 4738 Href = "javascript:void(0)" 4739 }; 4740 4741 <h2 class="@validVoucherCss">@Translate("Coupon Code")</h2> 4742 <div id="promoCodeContainer" class="DMForms col-xs-12 noPadding stepContainer" data-error="@voucherCodeErrorMessage"> 4743 @if (!voucherResult.Valid || voucherResult.Expired || voucherResult.Inactive) 4744 { 4745 if (!isCheckoutFlow) 4746 { 4747 <form action="@myCart" method="post"> 4748 @RenderField(new FieldSettings {Type = FieldType.Text, Label = Translate("Enter a Voucher Code"), SystemName = "EcomOrderVoucherCode", Value = GetString("Ecom:Order.Customer.VoucherCode"), IncludeWrapper = false}) 4749 @RenderField(new FieldSettings 4750 { 4751 Type = FieldType.Submit, 4752 SystemName = "applyVoucher", 4753 Value = Translate("Apply"), 4754 CssClass = "btn-default submitVoucher" 4755 }) 4756 </form> 4757 } 4758 else 4759 { 4760 <fieldset> 4761 @RenderField(new FieldSettings {Type = FieldType.Text, Label = Translate("Enter a Voucher Code"), SystemName = "EcomOrderVoucherCode", Value = GetString("Ecom:Order.Customer.VoucherCode"), IncludeWrapper = false}) 4762 @RenderBootstrapButton(submitVoucherBtn) 4763 </fieldset> 4764 } 4765 } 4766 </div> 4767 } 4768 4769 @helper InternalRenderTotalAmountLineCustom(string label, string value, bool isBold = false, CartOutputType outputType = CartOutputType.ReadOnly, string cssClass = "") 4770 { 4771 if (outputType == CartOutputType.Email) 4772 { 4773 <tr align="left"> 4774 <td> 4775 @InternalRenderValue(label, isBold) 4776 </td> 4777 <td> 4778 &nbsp; 4779 </td> 4780 <td class="noPadding" style="padding-right: 90px; text-align: right;"> 4781 @InternalRenderValue(value, isBold) 4782 </td> 4783 </tr> 4784 } 4785 else 4786 { 4787 <div class="col-xs-6 col-sm-7 clearLeft @cssClass"> 4788 @InternalRenderValue(label, isBold) 4789 </div> 4790 <div class="col-xs-6 col-sm-5 price pull-right noPadding-xs text-right @cssClass"> 4791 @InternalRenderValue(value, isBold) 4792 </div> 4793 } 4794 } 4795 4796 @helper InternalRenderOrderAmountsDisclaimerCustom(List<LoopItem> orderlines, bool isB2B = false) 4797 { 4798 var orderCannotBeShipped = orderlines.Any(ol => !ol.GetBoolean("Ecom:Product:Field.CanShipWithStandardCarrier")); 4799 @* Taxes and Shipping disclaimer *@ 4800 if (GetString("Ecom:Order.Taxes.Total.Price") == "0.00" || GetBoolean("Ecom:Order.ShippingFee.IsZero")) 4801 { 4802 <small class="col-xs-12 noPadding"> 4803 @if (GetBoolean("Ecom:Order.ShippingFee.IsZero") && GetString("Ecom:Order.Taxes.Total.Price") == "0.00") 4804 { 4805 @Translate(isB2B && orderCannotBeShipped ? "* Taxes and Shipping calculated at time of shipping" : "* Taxes and Shipping calculated at Checkout") 4806 } 4807 else 4808 { 4809 @Translate(isB2B && orderCannotBeShipped ? "*Taxes Calculated at time of shipping" : "*Taxes Calculated at Checkout") 4810 } 4811 </small> 4812 } 4813 } 4814 } 4815 @functions 4816 { 4817 public void UpdateUserEmailPermission(string email, string shopId) 4818 { 4819 var page = Dynamicweb.Extensibility.ServiceLocator.Current.GetPageService().GetPage(GetPageIdByNavigationTag("GeneralSettings")); 4820 var generalSettings = Dynamicweb.Content.Items.Item.GetItemById(page.ItemType, page.ItemId); 4821 var newsletterGroups = generalSettings["NewsletterConsentGroups"].ToString().Split(',').Select(s => Convert.ToInt32(s)).ToList(); 4822 4823 if (User.IsExtranetUserLoggedIn()) 4824 { 4825 var currentUser = User.GetCurrentUser(); 4826 if (currentUser.EmailAllowed != true) 4827 { 4828 currentUser.EmailAllowed = true; 4829 foreach (var groupId in newsletterGroups) 4830 { 4831 currentUser.AddToGroup(groupId); 4832 } 4833 currentUser.Save(); 4834 } 4835 } 4836 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) 4837 { 4838 var newsletterUser = new User(); 4839 newsletterUser.EmailAllowed = true; 4840 newsletterUser.UserName = "newsletter-" + email; 4841 newsletterUser.Email = email; 4842 newsletterUser.ShopID = shopId; 4843 foreach (var groupId in newsletterGroups) 4844 { 4845 newsletterUser.AddToGroup(groupId); 4846 } 4847 newsletterUser.Save(); 4848 } 4849 } 4850 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 4851 @using System 4852 @using System.Collections.Generic 4853 @using System.Globalization 4854 @using Dna.Frontend 4855 @using Dna.Frontend.Forms 4856 @using Dynamicweb.Rendering 4857 @using Dynamicweb.Frontend 4858 @using System.Linq 4859 @using System.Web 4860 @using Dna.Frontend.UI 4861 @using Dna.Validation 4862 @using Dynamicweb.Core 4863 @using Dynamicweb.Ecommerce 4864 @using Dynamicweb.Ecommerce.Orders 4865 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 4866 @using Dynamicweb.Ecommerce.Products 4867 @using Dynamicweb.Content.Items 4868 @using FieldType = Dynamicweb.Forms.FieldType 4869 @using FieldOption = Dna.Frontend.Forms.FieldOption 4870 @{ InitEditOrders();} 4871 @functions{ 4872 readonly string parameterAddProduct = "AddProduct"; 4873 readonly string parameterProductId = "ProductId"; 4874 readonly string parameterVariantId = "VariantId"; 4875 readonly string parameterQuantity = "Quantity"; 4876 readonly string parameterUpdateQuantity = "UpdateQuantity"; 4877 readonly string parameterDeleteOrderline = "DeleteOrderline"; 4878 readonly string parameterUpdateNote = "UpdateNote"; 4879 readonly string parameterOrderLineId = "OrderlineID"; 4880 readonly string parameterFinishSave= "FinishSave"; 4881 readonly string parameterCancel = "Cancel"; 4882 readonly string shippingInstructionsOrderFieldSystemName = "ShippingInstructions"; 4883 readonly string instanceIdentifierOrderlineFieldSystemName = "InstanceIdentifier"; 4884 readonly string noteOrderlineFieldSystemName = "Note"; 4885 readonly string isEditingOrderFieldSystemName = "IsEditing"; 4886 readonly string forceIntegrationOrderFieldSystemName = "ForceIntegration"; 4887 readonly string editedByOrderFieldSystemName = "EditedBy"; 4888 readonly string shippingFeeSurchargePortionOrderFieldSystemName = "ShippingFeeSurchargePortion"; 4889 string currentPageUrl = string.Empty; 4890 string errorMessage = string.Empty; 4891 OrderService orderService; 4892 OrderLineService orderlineService; 4893 4894 public void InitEditOrders() 4895 { 4896 orderService = new OrderService(); 4897 orderlineService = new OrderLineService(); 4898 } 4899 4900 public string GetOrderCustomFieldValue(Order order, string fieldSystemName) 4901 { 4902 var orderCustomField = order.OrderFieldValues.FirstOrDefault(of => of.OrderField.SystemName.Equals(fieldSystemName)); 4903 4904 if (orderCustomField == null) 4905 { 4906 return string.Empty; 4907 } 4908 4909 return orderCustomField.Value.ToString(); 4910 } 4911 4912 public void SetOrderCustomFieldValue(Order order, string fieldSystemName, object value) 4913 { 4914 var orderCustomField = order.OrderFieldValues.FirstOrDefault(of => of.OrderField.SystemName.Equals(fieldSystemName)); 4915 4916 if (orderCustomField != null) 4917 { 4918 orderCustomField.Value = value; 4919 } 4920 } 4921 4922 public bool EditOrder(Order order) 4923 { 4924 var orderModified = false; 4925 var productService = new ProductService(); 4926 var parameterOrderLineIdValue = Sanitize.Parameter(parameterOrderLineId); 4927 4928 if (Sanitize.Parameter(parameterAddProduct, ParameterType.Number).IsNotNullOrEmpty()) 4929 { 4930 var product = productService.GetProductById(Sanitize.Parameter(parameterProductId), Sanitize.Parameter(parameterVariantId), Pageview.Area.EcomLanguageId); 4931 if (product != null) 4932 { 4933 PrepareOrderToUpdate(order); 4934 var sameOrderLineAddedBefore = order.OrderLines.FirstOrDefault(ol => ol.ProductId.Equals(product.Id) 4935 && ol.ProductVariantId.Equals(product.VariantId) 4936 && (ol.get_OrderLineFieldValue(noteOrderlineFieldSystemName)?.Value.Equals(string.Empty) ?? false) 4937 && (ol.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName)?.Value.Equals(HttpContext.Current.Session.SessionID) ?? false)); 4938 4939 if (sameOrderLineAddedBefore != null) 4940 { 4941 UpdateOrderLineQuantity(order, sameOrderLineAddedBefore,(sameOrderLineAddedBefore.Quantity + Convert.ToDouble(Sanitize.Parameter(parameterQuantity, ParameterType.Number)))); 4942 SaveOrderChanges(order); 4943 orderModified = true; 4944 } 4945 else 4946 { 4947 var orderLine = new OrderLine(); 4948 orderLine.Order = order; 4949 orderlineService.SetProductInformation(orderLine, product); 4950 orderlineService.SetUnitPrice(orderLine, product.GetPrice(order.CurrencyCode, order.CustomerCountryCode)); 4951 if (orderLine.UnitPrice.Price == 0) 4952 { 4953 orderlineService.Delete(orderLine.Id); 4954 SaveOrderChanges(order); 4955 } 4956 else 4957 { 4958 orderLine.Quantity = Convert.ToDouble(Sanitize.Parameter(parameterQuantity, ParameterType.Number)); 4959 orderLine.OrderLineFieldValues.Add(new OrderLineFieldValue(noteOrderlineFieldSystemName, string.Empty)); 4960 orderLine.OrderLineFieldValues.Add(new OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName, System.Web.HttpContext.Current.Session.SessionID)); 4961 orderLine.OrderLineType = OrderLineType.Product; 4962 order.OrderLines.Add(orderLine, true); 4963 orderlineService.Save(orderLine); 4964 orderService.ForcePriceRecalculation(order); 4965 SaveOrderChanges(order); 4966 orderModified = true; 4967 } 4968 } 4969 4970 } 4971 } 4972 else if (parameterOrderLineIdValue.IsNotNullOrEmpty()) 4973 { 4974 var orderLine = order.OrderLines.FirstOrDefault(ol => ol.Id.Equals(parameterOrderLineIdValue)); 4975 if (orderLine != null) 4976 { 4977 if (Sanitize.Parameter(parameterUpdateQuantity, ParameterType.Number).IsNotNullOrEmpty()) 4978 { 4979 PrepareOrderToUpdate(order); 4980 UpdateOrderLineQuantity(order, orderLine, Convert.ToDouble(Sanitize.Parameter(parameterQuantity, ParameterType.Number))); 4981 SaveOrderChanges(order); 4982 orderModified = true; 4983 } 4984 else if(Sanitize.Parameter(parameterUpdateNote, ParameterType.LongText) != null) 4985 { 4986 var noteField = orderLine.get_OrderLineFieldValue(noteOrderlineFieldSystemName); 4987 if (noteField != null) 4988 { 4989 noteField.Value = Sanitize.Parameter(parameterUpdateNote, ParameterType.LongText); 4990 } 4991 else 4992 { 4993 orderLine.OrderLineFieldValues.Add(new OrderLineFieldValue(noteOrderlineFieldSystemName, Sanitize.Parameter(parameterUpdateNote, ParameterType.LongText))); 4994 } 4995 4996 orderlineService.Save(orderLine); 4997 4998 var duplicatedOrderLine = order.OrderLines.FirstOrDefault(ol => orderlineService.CanBeMerged(ol,orderLine) && !ol.Id.Equals(orderLine.Id)); 4999 if (duplicatedOrderLine != null) 5000 { 5001 PrepareOrderToUpdate(order); 5002 UpdateOrderLineQuantity(order, duplicatedOrderLine, duplicatedOrderLine.Quantity + orderLine.Quantity); 5003 DeleteOrderLine(order, orderLine); 5004 SaveOrderChanges(order); 5005 } 5006 5007 orderModified = true; 5008 } 5009 else if (Sanitize.Parameter(parameterDeleteOrderline, ParameterType.Number).IsNotNullOrEmpty()) 5010 { 5011 PrepareOrderToUpdate(order); 5012 DeleteOrderLine(order, orderLine); 5013 SaveOrderChanges(order); 5014 orderModified = true; 5015 } 5016 } 5017 } 5018 else if (Sanitize.Parameter(shippingInstructionsOrderFieldSystemName, ParameterType.LongText).IsNotNullOrEmpty()) 5019 { 5020 PrepareOrderToUpdate(order); 5021 SetOrderCustomFieldValue(order, isEditingOrderFieldSystemName, true); 5022 SaveOrderChanges(order); 5023 HttpContext.Current.Response.Cookies.Add(new HttpCookie(string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName), Sanitize.Parameter(shippingInstructionsOrderFieldSystemName, ParameterType.LongText))); 5024 orderModified = true; 5025 } 5026 5027 if (orderModified) 5028 { 5029 orderService.RemoveOrderCache(order.Id); 5030 } 5031 5032 return orderModified; 5033 } 5034 5035 private void UpdateOrderLineQuantity(Order order, OrderLine orderLine, double qty = 0) 5036 { 5037 orderLine.Quantity = qty; 5038 orderlineService.Save(orderLine); 5039 orderService.ForcePriceRecalculation(order); 5040 } 5041 5042 private void DeleteOrderLine(Order order, OrderLine orderLine) 5043 { 5044 order.OrderLines.RemoveLine(orderLine.Id); 5045 orderlineService.Delete(orderLine.Id); 5046 orderService.ForcePriceRecalculation(order); 5047 } 5048 5049 private void PrepareOrderToUpdate(Order order) 5050 { 5051 order.IsCart = true; 5052 order.Complete = false; 5053 } 5054 5055 private void SaveOrderChanges(Order order, bool isEditing = true) 5056 { 5057 UpdateOrderShippingMethod(order); 5058 SetOrderCustomFieldValue(order, isEditingOrderFieldSystemName, isEditing); 5059 SetOrderCustomFieldValue(order, forceIntegrationOrderFieldSystemName, !isEditing); 5060 orderService.ForcePriceRecalculation(order); 5061 order.IsCart = false; 5062 order.Complete = true; 5063 orderService.Save(order); 5064 } 5065 5066 private void UpdateOrderShippingMethod(Order order) 5067 { 5068 var orderLimit = Convert.ToDouble(Pageview.Area.Item["Order_Limit"]); 5069 var shippingSurcharge = Convert.ToDouble(Pageview.Area.Item["Shipping_Surcharge"]); 5070 var subtotal = order.OrderLines.Where(ol => ol.OrderLineType != OrderLineType.Discount && ol.OrderLineType != OrderLineType.Tax).Sum(olp => olp.Price.Price); 5071 5072 if (order.ShippingMethodId.IsNullOrEmpty() || orderLimit == 0) 5073 { 5074 return; 5075 } 5076 5077 var shippingMethodsRelations = GetShippingMethodsRelations(); 5078 5079 if (shippingMethodsRelations.ContainsKey(order.ShippingMethodId) && shippingMethodsRelations.ContainsValue(order.ShippingMethodId)) 5080 { 5081 return; 5082 } 5083 5084 // Order value increased 5085 if (shippingMethodsRelations.ContainsKey(order.ShippingMethodId) && subtotal > orderLimit) 5086 { 5087 UpdateOrderShippingMethod(order, shippingMethodsRelations[order.ShippingMethodId], 0); 5088 } 5089 // Order value decreased (when user cancels the changes) 5090 else if (shippingMethodsRelations.ContainsValue(order.ShippingMethodId) && subtotal < orderLimit) 5091 { 5092 UpdateOrderShippingMethod(order, shippingMethodsRelations.First(x => x.Value.Equals(order.ShippingMethodId)).Key, shippingSurcharge); 5093 } 5094 } 5095 5096 private void UpdateOrderShippingMethod(Order order, string shippingMethodId, double shippingSurcharge) 5097 { 5098 var shippingMethod = Shipping.GetShippingmethodById(shippingMethodId); 5099 if (shippingMethod == null) 5100 { 5101 return; 5102 } 5103 order.ShippingMethodId = shippingMethod.Id; 5104 order.ShippingMethod = shippingMethod.Name; 5105 order.ShippingMethodDescription = shippingMethod.Description; 5106 SetOrderCustomFieldValue(order, shippingFeeSurchargePortionOrderFieldSystemName, shippingSurcharge); 5107 orderService.ForcePriceRecalculation(order); 5108 } 5109 5110 private bool FinishAndSaveOrder(Order order) 5111 { 5112 foreach (var orderLine in order.OrderLines) 5113 { 5114 var instanceIdentifierOrderlineField = orderLine.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName); 5115 if (instanceIdentifierOrderlineField != null && orderLine.OrderLineType == OrderLineType.Product) 5116 { 5117 instanceIdentifierOrderlineField.Value = string.Empty; 5118 orderlineService.Save(orderLine); 5119 } 5120 } 5121 5122 if (HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)] != null) 5123 { 5124 SetOrderCustomFieldValue(order, shippingInstructionsOrderFieldSystemName, HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)].Value); 5125 HttpContext.Current.Response.Cookies.Add(new HttpCookie(string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)){ Expires = DateTime.Now.AddDays(-1d) }); 5126 } 5127 5128 SetOrderCustomFieldValue(order, isEditingOrderFieldSystemName, false); 5129 SetOrderCustomFieldValue(order, forceIntegrationOrderFieldSystemName, false); 5130 SetOrderCustomFieldValue(order, editedByOrderFieldSystemName, GetAuditUserName()); 5131 order.StateId = "OS15"; 5132 orderService.Save(order); 5133 5134 // Try to update order on the fly, if it fails it will be sent by on batch job 5135 var orderUpdatedInErp = Dna.Ecommerce.LiveIntegration.TemplatesHelper.UpdateOrder(order); 5136 if (!orderUpdatedInErp.HasValue || (orderUpdatedInErp.HasValue && !orderUpdatedInErp.Value)) 5137 { 5138 SetOrderCustomFieldValue(order, forceIntegrationOrderFieldSystemName, true); 5139 orderService.Save(order); 5140 } 5141 5142 return true; 5143 } 5144 5145 private bool CancelOrder(Order order) 5146 { 5147 var orderlinesToRemove = new List<string>(); 5148 5149 foreach (var orderLine in order.OrderLines) 5150 { 5151 var instanceIdentifierOrderlineField = orderLine.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName); 5152 if (instanceIdentifierOrderlineField != null && orderLine.OrderLineType == OrderLineType.Product && instanceIdentifierOrderlineField.Value.Equals(System.Web.HttpContext.Current.Session.SessionID)) 5153 { 5154 orderlinesToRemove.Add(orderLine.Id); 5155 } 5156 } 5157 5158 PrepareOrderToUpdate(order); 5159 5160 if (orderlinesToRemove.Any()) 5161 { 5162 foreach (var orderlineIdToRemove in orderlinesToRemove) 5163 { 5164 order.OrderLines.RemoveLine(orderlineIdToRemove); 5165 orderlineService.Delete(orderlineIdToRemove); 5166 } 5167 } 5168 5169 orderService.ForcePriceRecalculation(order); 5170 SaveOrderChanges(order, false); 5171 5172 if (HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)] != null) 5173 { 5174 HttpContext.Current.Response.Cookies.Add(new HttpCookie(string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)){ Expires = DateTime.Now.AddDays(-1d) }); 5175 } 5176 5177 return true; 5178 } 5179 5180 private string GetAuditUserName() 5181 { 5182 var user = Dna.Frontend.Users.GetRealUser(); 5183 5184 if (user == null) 5185 { 5186 return string.Empty; 5187 } 5188 5189 return user.UserName; 5190 } 5191 5192 private Dictionary<string, string> GetShippingMethodsRelations() 5193 { 5194 var results = new Dictionary<string, string>(); 5195 foreach (Item shippingMethod in ItemList.GetItemListById(Converter.ToInt32(Pageview.Area.Item["ShippingMethodsRelations"])).Relations) 5196 { 5197 var shippingMethodWithSurcharge = (shippingMethod["ShippingMethodWithSurcharge"] ?? "").ToString(); 5198 var shippingMethodWithoutSurcharge = (shippingMethod["ShippingMethodWithoutSurcharge"] ?? "").ToString(); 5199 5200 if (results.ContainsKey(shippingMethodWithSurcharge)) 5201 { 5202 continue; 5203 } 5204 5205 results.Add(shippingMethodWithSurcharge, shippingMethodWithoutSurcharge); 5206 } 5207 return results; 5208 } 5209 5210 private bool OrderStateChangedInErp(Order order) 5211 { 5212 var erpOrderState = Dna.Ecommerce.LiveIntegration.TemplatesHelper.ReadOrderState(order); 5213 return (string.IsNullOrEmpty(erpOrderState) || !order.StateId.Equals(erpOrderState)); 5214 } 5215 } 5216 5217 @helper RenderEditOrderNoOrder() 5218 { 5219 <p>@Translate("We are unable to render this order.")</p> 5220 @SnippetStart("jsOnLoad") 5221 <text>$(".paragraphText").hide();</text> 5222 @SnippetEnd("jsOnLoad") 5223 } 5224 5225 @helper RenderEditOrderCannotEdit() 5226 { 5227 <p>@Translate("Please contact Hewitt as your order has already been processed and cannot be edited.")</p> 5228 @SnippetStart("jsOnLoad") 5229 <text>$(".paragraphText").hide();</text> 5230 @SnippetEnd("jsOnLoad") 5231 } 5232 5233 @helper RenderEditOrderFinishSaveCancelButtons(bool showSave, bool showCancel, string containerCssClass="") 5234 { 5235 <div class="col-xs-12 @containerCssClass buttonContainer"> 5236 @if (showSave) 5237 { 5238 <form class="displayInline pull-right" action="@currentPageUrl" method="post"> 5239 @RenderField(FieldSettings.CreateHiddenField(parameterFinishSave, "1")) 5240 @RenderField(FieldSettings.CreateSubmitField(Translate(" Finish and Save"), "btn-default finishSaveCancel")) 5241 </form> 5242 } 5243 5244 @if (showCancel) 5245 { 5246 <form class="displayInline pull-right" action="@currentPageUrl" method="post"> 5247 @RenderField(FieldSettings.CreateHiddenField(parameterCancel, "1")) 5248 @RenderField(FieldSettings.CreateSubmitField(Translate(" Cancel"), "btn-primary finishSaveCancel")) 5249 </form> 5250 } 5251 </div> 5252 } 5253 5254 @helper RenderEditOrder(Order order) 5255 { 5256 const string addressLabels = "hidden"; 5257 const string labelCss = "col-xs-6 col-sm-3"; 5258 const string valueCss = "col-xs-6 col-sm-9"; 5259 5260 currentPageUrl = SearchEngineFriendlyURLs.GetFriendlyUrl(string.Concat("Default.aspx?Id=", Pageview.Page.ID.ToString(CultureInfo.InvariantCulture), "&OrderID=", order.Id, "&OrderSecret=", order.Secret)); 5261 5262 var customerAddressHash = GetAddressHash(order.CustomerAddress, order.CustomerAddress2, order.CustomerCity, order.CustomerRegion, order.CustomerZip, order.CustomerCountry); 5263 var deliveryAddressHash = GetAddressHash(order.DeliveryAddress, order.DeliveryAddress2, order.DeliveryCity, order.DeliveryRegion, order.DeliveryZip, order.DeliveryCountry); 5264 var areAddessesTheSame = customerAddressHash == deliveryAddressHash; 5265 var addressTitle = areAddessesTheSame ? Translate("Billing and Shipping Address") : Translate("Billing Address"); 5266 var addressClass = areAddessesTheSame ? "col-sm-12" : " col-sm-6"; 5267 var poNumber = GetOrderCustomFieldValue(order, "PONumber"); 5268 var shippingInstructions = GetOrderCustomFieldValue(order, shippingInstructionsOrderFieldSystemName); 5269 var isEditingOrder = GetOrderCustomFieldValue(order, isEditingOrderFieldSystemName).Equals("true", StringComparison.InvariantCultureIgnoreCase); 5270 5271 if (HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)] != null) 5272 { 5273 shippingInstructions = HttpContext.Current.Request.Cookies[string.Concat(order.Id, "-", shippingInstructionsOrderFieldSystemName)].Value; 5274 } 5275 5276 <div id="orderDetailContainer" class="orderContainer editOrder"> 5277 <div class="row generalMarginBottom"> 5278 <form class="col-xs-12 col-sm-8 quickAddForm" action="@currentPageUrl" autocomplete="off" method="post"> 5279 @RenderField(FieldSettings.CreateHiddenField("getproductinfo", "true")) 5280 @RenderField(FieldSettings.CreateHiddenField(parameterAddProduct, "1")) 5281 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterProductId, Id = "quickAddProductId"}) 5282 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterVariantId, Id = "quickAddVariantId"}) 5283 @RenderField(new FieldSettings 5284 { 5285 Type = FieldType.Text, 5286 Label = Translate("SKU"), 5287 LabelCssClass = "quickAddPartNumberContainer", 5288 SystemName = "q", 5289 Id = "quickAddPartNumber", 5290 CssClass = "quickAddPartNumber", 5291 IncludeWrapper = true, 5292 Placeholder = Translate("Enter SKU"), 5293 WrapperCssClass = "quickAddPartNumber" 5294 }) 5295 @RenderQuantitySelector(false, 99999, 2) 5296 <fieldset class="quickAddSubmitContainer pull-left"> 5297 @RenderBootstrapButton(new BootstrapButtonSettings 5298 { 5299 Label = RenderIcon("fa-shopping-cart") + " " + Translate("Add to Order"), 5300 CssClass = "quickAddSubmit btn btn-sm btn-bg", 5301 ButtonType = BootstrapButtonSettings.BootstrapButtonType.Button, 5302 Attributes = new Dictionary<string, string> {{"type", "submit"}} 5303 }) 5304 </fieldset> 5305 </form> 5306 @RenderEditOrderFinishSaveCancelButtons(isEditingOrder, true, "col-sm-4 pull-right topButton") 5307 </div> 5308 5309 <div class="row"> 5310 <header id="toggleOrderDetailsHeader" class="col-xs-12"> 5311 <h2>@RenderIcon("fa-plus-circle") @Translate("Order Details")</h2> 5312 </header> 5313 <div id="toggleOrderDetails"> 5314 <div class="col-xs-12 col-sm-6 blockContent"> 5315 <dl class="row"> 5316 @RenderDataListItem(string.Concat(Translate("Order Number"), ":"), order.Id, labelCss, valueCss, string.Empty, true) 5317 @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) 5318 @RenderDataListItem(string.Concat(Translate("Payment Method"), ":"), order.PaymentMethod, labelCss, valueCss, string.Empty, true) 5319 @if (poNumber.IsNotNullOrEmpty()) 5320 { 5321 @RenderDataListItem(string.Concat(Translate("PO Number"), ":"), poNumber, labelCss, valueCss, string.Empty, true) 5322 } 5323 @RenderDataListItem(string.Concat(Translate("Shipping Method"), ":"), order.ShippingMethod, labelCss, valueCss, string.Empty, true) 5324 </dl> 5325 </div> 5326 <div class="col-xs-12 @addressClass blockContent clear"> 5327 <h2 class="title">@addressTitle</h2> 5328 <dl> 5329 @RenderDataListItem(Translate("Name"), order.CustomerName, addressLabels, string.Empty) 5330 @RenderDataListItem(Translate("Address"), string.Concat(order.CustomerAddress, " ", order.CustomerAddress2), addressLabels, string.Empty) 5331 @RenderDataListItem(Translate("Country"), string.Concat(order.CustomerCity, ", ", order.CustomerRegion, " ", order.CustomerZip, " <br/>", order.CustomerCountry), addressLabels, string.Empty) 5332 @RenderDataListItem(Translate("Phone"), order.CustomerPhone, addressLabels, string.Empty) 5333 @RenderDataListItem(Translate("Email"), order.CustomerEmail, addressLabels, string.Empty) 5334 </dl> 5335 </div> 5336 @if (!areAddessesTheSame) 5337 { 5338 <div class="col-xs-12 col-sm-6 blockContent"> 5339 <h2 class="title">@Translate("Shipping Address")</h2> 5340 <dl> 5341 @RenderDataListItem(Translate("Name"), order.DeliveryName, addressLabels, string.Empty) 5342 @RenderDataListItem(Translate("Address"), string.Concat(order.DeliveryAddress, " ", order.DeliveryAddress2), addressLabels, string.Empty) 5343 @RenderDataListItem(Translate("Country"), string.Concat(order.DeliveryCity, ", ", order.DeliveryRegion, " ", order.DeliveryZip, " <br/>", order.DeliveryCountry), addressLabels, string.Empty) 5344 @RenderDataListItem(Translate("Phone"), order.DeliveryPhone, addressLabels, string.Empty) 5345 @RenderDataListItem(Translate("Email"), order.DeliveryEmail, addressLabels, string.Empty) 5346 </dl> 5347 </div> 5348 } 5349 @if (shippingInstructions.IsNotNullOrEmpty()) 5350 { 5351 <div id="shippingInstructions" class="col-xs-12 blockContent"> 5352 <h2 class="title">@RenderIcon("fa-edit", Translate("Shipping Instructions"), IconPosition.Right)</h2> 5353 <form class="cartChange" method="POST" action="@currentPageUrl"> 5354 @RenderField(new FieldSettings(){Type = FieldType.Textarea, SystemName = shippingInstructionsOrderFieldSystemName, Value = shippingInstructions, Attributes = new Dictionary<string, string>{{"readonly","readonly"}, {"maxlength", "62"}}}) 5355 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"))) 5356 </form> 5357 </div> 5358 } 5359 </div> 5360 </div> 5361 <div class="col-xs-12 noPadding lastStepProducts" id="productContent"> 5362 @RenderEditOrderCartContents(order.OrderLines) 5363 </div> 5364 5365 <div class="col-xs-12 totalValues noPadding"> 5366 @RenderEditOrderContentsSummary(order) 5367 </div> 5368 @RenderEditOrderFinishSaveCancelButtons(isEditingOrder, false, "noPadding") 5369 </div> 5370 5371 if (order.CustomerComment.IsNotNullOrEmpty()) 5372 { 5373 <div class="row" id="giftMessageContent"> 5374 <div class="col-xs-12"> 5375 <h2 class="title">@Translate("Gift Message")</h2> 5376 <div>@order.CustomerComment</div> 5377 </div> 5378 </div> 5379 } 5380 @SnippetStart("jsOnLoad") 5381 @: onLoadEditOrder('@errorMessage', '@Translate("Are you sure you want to delete the item")', @isEditingOrder.ToString().ToLowerInvariant()); 5382 @SnippetEnd("jsOnLoad") 5383 } 5384 5385 @helper RenderEditOrderContentsSummary(Order order, CartOutputType outputType = CartOutputType.ReadOnly) 5386 { 5387 var voucherResult = PromoCodeChecker.CheckOrderPromoCode(order.VoucherCode); 5388 var orderTaxTotal = order.OrderLines.Where(t => t.OrderLineType.Equals(OrderLineType.Tax)).Sum(s => s.Price.Price); 5389 var orderDiscount = order.OrderLines.Where(t => t.OrderLineType.Equals(OrderLineType.Discount) || t.OrderLineType.Equals(OrderLineType.ProductDiscount) && t.ParentLineId.IsNullOrEmpty()).Sum(s => s.Price.Price); 5390 5391 <div id="totalPriceContainer" class="col-xs-12 col-sm-5 noPadding pull-right noPadding-xs"> 5392 @if (voucherResult.Valid && !voucherResult.Expired && !voucherResult.Inactive && order.VoucherCode.IsNotNullOrEmpty()) 5393 { 5394 <div class="col-xs-12 noPadding"> 5395 <div class="discountContainer col-xs-12"> 5396 <div class="row"> 5397 <span class="col-xs-8 col-sm-7 noPadding">@Translate("Voucher"): @EcommerceHelpers.GetVoucherName(order.VoucherCode)</span> 5398 </div> 5399 </div> 5400 </div> 5401 } 5402 5403 @if (order.TotalPoints != null && order.TotalPoints.Value > 0) 5404 { 5405 @InternalRenderTotalAmountLine(Translate("Loyalty Points Spent"), order.TotalPoints.Value.ToString(CultureInfo.InvariantCulture), false, outputType) 5406 } 5407 5408 @if (order.RewardTotalPoints != null && order.RewardTotalPoints.Value > 0) 5409 { 5410 @InternalRenderTotalAmountLine(Translate("Loyalty Points Earned"), order.RewardTotalPoints.Value.ToString(CultureInfo.InvariantCulture), false, outputType) 5411 } 5412 5413 @if (orderDiscount < 0) 5414 { 5415 @InternalRenderTotalAmountLine(Translate("Order Savings"), Services.Currencies.Format(order.Currency, orderDiscount, true), false, outputType) 5416 } 5417 5418 @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) 5419 5420 @if (order.ShippingMethodId.IsNotNullOrEmpty() || order.ShippingMethod.IsNotNullOrEmpty()) 5421 { 5422 var shippingSurcharge = Converter.ToInt32(GetOrderCustomFieldValue(order, shippingFeeSurchargePortionOrderFieldSystemName)); 5423 var shippingMethodPrice = order.ShippingFee.Price; 5424 if (shippingSurcharge > 0 && shippingMethodPrice > 0) 5425 { 5426 shippingMethodPrice -= shippingSurcharge; 5427 } 5428 5429 @InternalRenderTotalAmountLine(order.ShippingMethod.IsNotNullOrEmpty() ? order.ShippingMethod : order.ShippingMethodId, shippingMethodPrice > 0 ? Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingMethodPrice) : "&nbsp;", false, outputType) 5430 5431 if (shippingSurcharge > 0) 5432 { 5433 @InternalRenderTotalAmountLine(Translate("Shipping Surcharge"), Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, shippingSurcharge), false, outputType) 5434 } 5435 } 5436 5437 @if (orderTaxTotal > 0) 5438 { 5439 @InternalRenderTotalAmountLine(Translate("Taxes"), Services.Currencies.Format(order.Currency, orderTaxTotal, true), false, outputType) 5440 } 5441 5442 @InternalRenderTotalAmountLine(Translate("Total"), order.Price.PriceFormatted, true, outputType) 5443 </div> 5444 } 5445 5446 @helper RenderEditOrderCartContents(OrderLineCollection orderLines) 5447 { 5448 <div class="showCartHeader col-sm-12 noPadding"> 5449 <div class="hidden-xs col-sm-2 col-xs-offset-6 noPadding mdAlignRight">@Translate("Dealer price")</div> 5450 <div class="hidden-xs col-sm-2 noPadding mdAlignRight">@Translate("Qty")</div> 5451 <div class="col-sm-2 totalPrice text-right">@Translate("Total Price")</div> 5452 </div> 5453 5454 <ul class="cartProductsList"> 5455 @foreach (var orderLine in orderLines.Where(ol => ol.ParentLineId.IsNullOrEmpty())) 5456 { 5457 if (orderLine.OrderLineType != OrderLineType.Discount && orderLine.OrderLineType != OrderLineType.Tax) 5458 { 5459 @RenderEditOrderCartContentsLine(orderLines, orderLine) 5460 } 5461 } 5462 </ul> 5463 } 5464 5465 @helper RenderEditOrderCartContentsLine(OrderLineCollection orderLines, OrderLine orderLine) 5466 { 5467 var isDiscountOrderline = orderLine.DiscountId.IsNotNullOrEmpty() || orderLine.ParentLineId.IsNotNullOrEmpty(); 5468 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); 5469 var orderLineNoteField = orderLine.get_OrderLineFieldValue(noteOrderlineFieldSystemName); 5470 var orderLineInstanceIdentifierField = orderLine.get_OrderLineFieldValue(instanceIdentifierOrderlineFieldSystemName); 5471 var isCurrentSessionOrderline = (orderLineInstanceIdentifierField != null ? orderLineInstanceIdentifierField.Value : string.Empty).Equals(System.Web.HttpContext.Current.Session.SessionID) && orderLine.OrderLineType == OrderLineType.Product; 5472 var imageSrc = string.Empty; 5473 try 5474 { 5475 imageSrc = orderLine.ProductId.IsNotNullOrEmpty() ? Dna.Hewitt.Images.GetHewittImagePath(orderLine.Product) : string.Empty; 5476 } 5477 catch (Exception ex) 5478 { 5479 imageSrc = string.Empty; 5480 } 5481 5482 imageSrc = imageSrc.StartsWith("/files", StringComparison.InvariantCultureIgnoreCase) ? imageSrc : string.Concat("/Files", imageSrc); 5483 var productContainerCssClass = "col-xs-8 col prodName noPadding"; 5484 productContainerCssClass = string.Concat(productContainerCssClass, isDiscountOrderline ? " col-xs-offset-4" : string.Empty); 5485 5486 <li class="col-xs-12 noPadding" data-isdiscount="@isDiscountOrderline"> 5487 <div class="col-xs-12 col-sm-6 noPaddingLeft noPadding-xs"> 5488 @if (!isDiscountOrderline) 5489 { 5490 @RenderImage(new ImageSettings 5491 { 5492 Source = Images.GetImage(imageSrc, 95, 95), 5493 AltText = orderLine.ProductName, 5494 Href = productUrl, 5495 IncludeWrapper = true, 5496 WrapperElement = Sanitize.Parameter("print").IsNotNullOrEmpty() ? "div" : "figure", 5497 WrapperCssClass = "text-center col-xs-12 col-sm-4" 5498 }) 5499 } 5500 5501 <div class="@productContainerCssClass"> 5502 <h2> 5503 <a href="@productUrl"> 5504 <strong>@orderLine.ProductName</strong> 5505 @if (orderLine.ProductVariantText.IsNotNullOrEmpty()) 5506 { 5507 <br/> 5508 <small>@orderLine.ProductVariantText</small> 5509 } 5510 </a> 5511 </h2> 5512 @if (orderLine.ProductNumber.IsNotNullOrEmpty()) 5513 { 5514 <div class="itemDetails">@Translate("Item number"): @orderLine.ProductNumber</div> 5515 } 5516 5517 @if (orderLineNoteField != null) 5518 { 5519 <div class="orderlineNote"> 5520 @if (orderLineNoteField.Value.IsNotNullOrEmpty()) 5521 { 5522 <div> 5523 <strong>@orderLineNoteField.OrderLineFieldName:</strong> @orderLineNoteField.Value<br/> 5524 </div> 5525 if (isCurrentSessionOrderline) 5526 { 5527 <a href="#edit-note@( orderLine.Id)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Edit Note")</a> 5528 } 5529 } 5530 else if (isCurrentSessionOrderline) 5531 { 5532 <div> 5533 <a href="#edit-note@( orderLine.Id)" class="fancybox">@RenderIcon("fa-edit")&nbsp; @Translate("Add Note")</a> 5534 </div> 5535 } 5536 </div> 5537 if (isCurrentSessionOrderline) 5538 { 5539 <div class="hidden"> 5540 <div id="edit-note@( orderLine.Id)" style="width: 460px;"> 5541 <form class="cartChange" method="POST" action="@currentPageUrl"> 5542 @RenderField(FieldSettings.CreateHiddenField(parameterOrderLineId, orderLine.Id, String.Concat(noteOrderlineFieldSystemName, "_", parameterOrderLineId, "_", orderLine.Id))) 5543 <h2>@Translate("Product Note")</h2> 5544 @orderLineNoteField.OrderLineFieldName:<br/> 5545 @RenderField(new FieldSettings 5546 { 5547 Type = FieldType.Text, 5548 Id = string.Concat(noteOrderlineFieldSystemName, parameterOrderLineId, orderLine.Id), 5549 SystemName = parameterUpdateNote, 5550 Attributes = {{"size", orderLineNoteField.OrderLineFieldLength.ToString()}, {"maxlength", "80"}}, 5551 Value = orderLineNoteField.Value 5552 }) 5553 <br/> 5554 @RenderField(FieldSettings.CreateSubmitField(Translate("Save"), "btn btn-bg"))<br/> 5555 </form> 5556 </div> 5557 </div> 5558 } 5559 } 5560 </div> 5561 </div> 5562 5563 <div class="col-xs-8 col-sm-offset-0 col-sm-2 price noPadding mdAlignRight"> 5564 @if(isDiscountOrderline) 5565 { 5566 <text>&nbsp;</text> 5567 } 5568 else 5569 { 5570 if (orderLine.OrderLineType == OrderLineType.PointProduct && orderLine.UnitPoints != null) 5571 { 5572 @: @string.Format("{0} {1}", orderLine.UnitPoints, Translate(orderLine.UnitPoints.Equals(1.00) ? "point" : "points")) 5573 } 5574 else if (orderLine.Product.DefaultPrice > 0 && !orderLine.Product.DefaultPrice.Equals(orderLine.UnitPrice.Price)) 5575 { 5576 <del>@Services.Currencies.Format(orderLine.Price.Currency, orderLine.Product.DefaultPrice, true)</del> 5577 <br/> 5578 <span>@orderLine.UnitPrice.PriceFormatted</span> 5579 } 5580 else 5581 { 5582 @orderLine.UnitPrice.PriceFormatted 5583 } 5584 } 5585 </div> 5586 5587 5588 <div class="col-xs-6 col-sm-offset-0 col-sm-2 quantity noPaddingLeft mdAlignRight"> 5589 @if (isDiscountOrderline) 5590 { 5591 <text>&nbsp;</text> 5592 } 5593 else 5594 { 5595 <strong class="hidden-sm hidden-md hidden-lg pull-left">@Translate("Qty")&nbsp;&nbsp;</strong> 5596 if (isCurrentSessionOrderline) 5597 { 5598 <form class="cartChange" method="POST" action="@currentPageUrl"> 5599 @RenderField(FieldSettings.CreateHiddenField("getproductinfo", "true", String.Concat("getproductinfo_", orderLine.Id))) 5600 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterUpdateQuantity, Id = string.Concat(parameterQuantity, orderLine.Id), Value = "1"}) 5601 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterOrderLineId, Id = string.Concat(parameterOrderLineId, orderLine.Id), Value = orderLine.Id}) 5602 @InternalRenderQuantityField(999999, 999999, Convert.ToInt32(orderLine.Quantity), parameterQuantity, 10, true, orderLine.ProductVariantText.IsNotNullOrEmpty(), 0, orderLine.Id) 5603 </form> 5604 } 5605 else 5606 { 5607 <span>@orderLine.Quantity</span> 5608 } 5609 } 5610 </div> 5611 5612 <div class="col-xs-6 col-sm-2 totalPrice noPadding text-right noPadding-xs mdAlignRight"> 5613 @orderLine.Price.PriceFormatted 5614 @if (isCurrentSessionOrderline) 5615 { 5616 <form class="cartChange displayInline" method="POST" action="@currentPageUrl"> 5617 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterDeleteOrderline, Id = string.Concat(parameterDeleteOrderline, orderLine.Id), Value = "1"}) 5618 @RenderField(new FieldSettings {Type = FieldType.Hidden, SystemName = parameterOrderLineId, Id = string.Concat(parameterOrderLineId, orderLine.Id), Value = orderLine.Id}) 5619 <a class="removeFromCart editOrder" href="javascript:void(0);"> 5620 @RenderIcon("fa-times") 5621 </a> 5622 </form> 5623 } 5624 </div> 5625 </li> 5626 foreach (var orderLineChild in orderLines.Where(ol => ol.ParentLineId.IsNotNullOrEmpty() && ol.ParentLineId.Equals(orderLine.Id))) 5627 { 5628 if (orderLineChild.OrderLineType != OrderLineType.Discount && orderLineChild.OrderLineType != OrderLineType.Tax) 5629 { 5630 @RenderEditOrderCartContentsLine(orderLines, orderLineChild) 5631 } 5632 } 5633 }@inherits RazorTemplateBase<RazorTemplateModel<Template>> 5634 @using Dynamicweb.Core 5635 @using Dynamicweb.Rendering 5636 @using Dna.Frontend.UI 5637 @using System 5638 @using System.Web 5639 @using System.Collections.Generic 5640 @using System.Data.SqlTypes 5641 @using System.Globalization 5642 @using Dynamicweb.Frontend 5643 @using System.Linq 5644 @using Dna.Frontend.Forms 5645 @using Dna.Validation 5646 @using Dynamicweb.Ecommerce 5647 @using Dynamicweb.Forms 5648 @using System.Web.Script.Serialization 5649 @{ 5650 @helper RenderActionCc(IconAction action, string href = "", string title = "", string onClickConfirm = "") 5651 { 5652 var attributes = new Dictionary<string, string>(); 5653 5654 if (title.IsNotNullOrEmpty()) 5655 { 5656 attributes.Add("title", title); 5657 } 5658 if (onClickConfirm.IsNotNullOrEmpty()) 5659 { 5660 attributes.Add("onclick", "return confirm('" + onClickConfirm + "');"); 5661 } 5662 if (href.IsNotNullOrEmpty()) 5663 { 5664 attributes.Add("href", href); 5665 } 5666 @RenderActionCc(action, href, attributes) 5667 } 5668 5669 @helper RenderActionCc(IconAction action, string href, Dictionary<string, string> attributes) 5670 { 5671 var icon = string.Empty; 5672 var linkAttributes = string.Empty; 5673 var label = Translate(action.ToString()); 5674 5675 switch (action) 5676 { 5677 case IconAction.Add: 5678 break; 5679 case IconAction.View: 5680 icon = "fa-eye"; 5681 break; 5682 case IconAction.Edit: 5683 break; 5684 case IconAction.Cancel: 5685 case IconAction.Remove: 5686 icon = "fa-times"; 5687 break; 5688 case IconAction.Delete: 5689 icon = "fa-trash"; 5690 break; 5691 case IconAction.Print: 5692 icon = "fa-print"; 5693 attributes.Add("target", "_blank"); 5694 label = string.Empty; 5695 break; 5696 case IconAction.Save: 5697 break; 5698 case IconAction.Reset: 5699 break; 5700 case IconAction.Undo: 5701 break; 5702 case IconAction.Reorder: 5703 icon = "fa-repeat"; 5704 break; 5705 case IconAction.SetDefault: 5706 icon = "fa-times"; 5707 label = string.Empty; 5708 break; 5709 case IconAction.IsDefault: 5710 icon = "fa-check"; 5711 label = string.Empty; 5712 break; 5713 default: 5714 throw new NotSupportedException("An action is needed to render this helper!"); 5715 } 5716 if (icon.IsNotNullOrEmpty()) 5717 { 5718 if (href.IsNotNullOrEmpty()) 5719 { 5720 @GetHtmlElement("a", GetAttributes(attributes)) 5721 @RenderIcon(icon, label) 5722 @GetHtmlElement("a", true) 5723 } 5724 else if (label.IsNullOrEmpty()) 5725 { 5726 @RenderIcon(icon) 5727 } 5728 } 5729 5730 } 5731 5732 @helper RenderTabWithOrdersList(List<LoopItem> ordersLoop, string noOrdersMessage = "", int sendOrderPage = 0, string detailPageBase = "") 5733 { 5734 var userDisallowOrderingFieldValue = Dna.Frontend.Users.GetRealUser().CustomFieldValues.First(x => x.CustomField.SystemName == "AccessUser_DisallowOrdering").Value; 5735 var isUserOrderDisallowed = (userDisallowOrderingFieldValue != null && userDisallowOrderingFieldValue.ToString() == "True"); 5736 var sendOrderParagraphId = GetParagraphIdFromCc(); 5737 var excludedColumns = new string[] {"OrderSecret", "BackOrdered", "IsEditing"}; 5738 <div class="col-xs-12 noPadding" id="ordersListContainer"> 5739 @if (ordersLoop.Any()) 5740 { 5741 var editPageBase = SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("EditOrder")) + "?OrderID="; 5742 var isB2B = Dna.Hewitt.Helpers.IsUserB2B(); 5743 <table id="myOrdersTable" class="col-xs-12 noPadding text-left evenTable"> 5744 @RenderDataListTableHead(excludedColumns, true) 5745 <tbody> 5746 @foreach (var row in ordersLoop) 5747 { 5748 var orderId = row.GetString("OrderID"); 5749 var detailPage = string.Concat(detailPageBase, "?OrderId=", orderId, "&OrderSecret=", row.GetString("OrderSecret")); 5750 var editPage = editPageBase + orderId + "&OrderSecret=" + row.GetString("OrderSecret") + "&edit=1"; 5751 var print = detailPage + "&amp;print=true"; 5752 var resendOrder = SearchEngineFriendlyURLs.GetFriendlyUrl(sendOrderPage) + "?CC" + sendOrderParagraphId + "=Resend&OrderID=" + orderId; 5753 <tr> 5754 @foreach (var rowValue in row.GetLoop("Row").Where(c => !excludedColumns.Contains(c.GetString("Row.ColumnName")))) 5755 { 5756 var columnName = rowValue.GetString("Row.ColumnName"); 5757 <td data-th="@Translate(columnName)"> 5758 @if (columnName.Contains("Price")) 5759 { 5760 @Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, rowValue.GetDouble("Row.Value")) 5761 } 5762 else if (columnName == "OrderID") 5763 { 5764 <a href="@detailPage">@rowValue.GetString("Row.Value")</a> 5765 } 5766 else 5767 { 5768 switch (rowValue.GetValue("Row.Value").GetType().ToString()) 5769 { 5770 case "System.DateTime": 5771 @rowValue.GetDate("Row.Value").ToString("MM/dd/yyyy") 5772 break; 5773 case "System.Double": 5774 @rowValue.GetDouble("Row.Value") 5775 break; 5776 default: 5777 @rowValue.GetString("Row.Value") 5778 break; 5779 } 5780 } 5781 </td> 5782 } 5783 <td data-th="@Translate("Actions")" class="actions" data-th='@Translate("Actions")'> 5784 @if (!isUserOrderDisallowed && isB2B && Pageview.Page.ID.Equals(GetPageIdByNavigationTag("openOrders"))) 5785 { 5786 @RenderBootstrapButton(new BootstrapButtonSettings 5787 { 5788 Label = "Edit", 5789 CssClass = "btn-link edit-order-button", 5790 IconCssClass = "fa-edit", 5791 Attributes = new Dictionary<string, string> 5792 { 5793 {"title", Translate("Edit list")}, 5794 {"data-href", editPage}, 5795 {"data-toggle", "modal"}, 5796 {"data-target", "#modal-edit-order"} 5797 } 5798 }) 5799 } 5800 @if (sendOrderParagraphId> 0) 5801 { 5802 @RenderBootstrapButton(new BootstrapButtonSettings 5803 { 5804 CssClass = "noPadding viewOrderBtn", 5805 Label = Translate("View"), 5806 Href = detailPage, 5807 ButtonType = BootstrapButtonSettings.BootstrapButtonType.Anchor 5808 }) 5809 ; 5810 @RenderBootstrapButton(new BootstrapButtonSettings 5811 { 5812 Label = "Reorder", 5813 CssClass = "reorderBtn noPaddingRight", 5814 IconCssClass = "fa-repeat", 5815 Attributes = new Dictionary<string, string> 5816 { 5817 {"data-href", "/Default.aspx?ID=" + sendOrderPage + "&CC" + sendOrderParagraphId + "=Orders&ReorderID=" + row.GetString("OrderID") + "&redirect=false"} 5818 } 5819 }) 5820 @RenderAction(IconAction.Print, print) 5821 <a class="emailResend" 5822 data-resend-href="@resendOrder" 5823 href="@( SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("OrderEmailAddressesPopup")) + "?CC" + sendOrderParagraphId + "=Resend&OrderID=" + orderId)"> 5824 @RenderIcon("fa-envelope") 5825 </a> 5826 } 5827 </td> 5828 </tr> 5829 } 5830 </tbody> 5831 </table> 5832 @RenderPaging( 5833 GetInteger("DwPaging.PageCount"), 5834 "DWPagingPageNum", 5835 GetString("DwPaging.PreviousPageLink"), 5836 GetString("DwPaging.NextPageLink"), 5837 GetInteger("DwPaging.CurrentPage") 5838 ) 5839 } 5840 else 5841 { 5842 @noOrdersMessage 5843 } 5844 </div> 5845 } 5846 5847 5848 @helper RenderReportTabFilters(List<LoopItem> reportsListLoop, string[] dropdownFilterFields = null) 5849 { 5850 dropdownFilterFields = dropdownFilterFields ?? new string[0]; 5851 5852 var today = DateTime.Now; 5853 var currentMonth = new DateTime(today.Year, today.Month, 1); 5854 var lastDayOfCurrentMonth = currentMonth.AddMonths(1).AddDays(-1); 5855 var firstDayOfLastMonth = currentMonth.AddMonths(-1); 5856 var lastDayOfLastMonth = currentMonth.AddDays(-1); 5857 var lastTwoMonths = currentMonth.AddMonths(-2); 5858 var lastThreeMonths = currentMonth.AddMonths(-3); 5859 var lastTwelveMonths = currentMonth.AddMonths(-12); 5860 var searchOrdersPageId = Pageview.Page.ID; 5861 5862 var reqDateFrom = Sanitize.Parameter("startdate", ParameterType.Date); 5863 var reqStateFilter = Sanitize.Parameter("stateFilter"); 5864 5865 var queryParameters = HttpUtility.ParseQueryString(Dynamicweb.Context.Current.Request.Url.Query); 5866 queryParameters = Dna.UrlServices.Helpers.UpdateQueryStringKeyValue(queryParameters, "ID", GetPageIdByNavigationTag(Pageview.Page.ID.Equals(GetPageIdByNavigationTag("OrdersOnReports")) ? "OrdersCSV" : "CommissionsCSV").ToString()); 5867 5868 var dateFilter = new FieldSettings 5869 { 5870 Type = FieldType.Select, 5871 Id = "dateFilter", 5872 SystemName = "dateFilter", 5873 CssClass = "selectpicker", 5874 IncludeWrapper = true, 5875 WrapperCssClass = "col-xs-12 col-sm-3 noPadding pull-left", 5876 FieldOptionsList = new List<FieldOption>() 5877 }; 5878 5879 dateFilter.FieldOptionsList.Add(new FieldOption 5880 { 5881 Label = Translate("Current Month"), 5882 Value = "CurrentMonth", 5883 IsSelected = string.Compare(reqDateFrom, currentMonth.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5884 Attributes = 5885 { 5886 {"data-fromMonth", currentMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5887 {"data-toMonth", lastDayOfCurrentMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5888 } 5889 }); 5890 5891 dateFilter.FieldOptionsList.Add(new FieldOption 5892 { 5893 Label = Translate("Last Month"), 5894 Value = "LastMonth", 5895 IsSelected = string.Compare(reqDateFrom, firstDayOfLastMonth.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5896 Attributes = 5897 { 5898 {"data-fromMonth", firstDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5899 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5900 } 5901 }); 5902 5903 dateFilter.FieldOptionsList.Add(new FieldOption 5904 { 5905 Label = Translate("Last 2 Months"), 5906 Value = "Last2Months", 5907 IsSelected = string.Compare(reqDateFrom, lastTwoMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5908 Attributes = 5909 { 5910 {"data-fromMonth", lastTwoMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture)}, 5911 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5912 } 5913 }); 5914 5915 dateFilter.FieldOptionsList.Add(new FieldOption 5916 { 5917 Label = Translate("Last 3 Months"), 5918 Value = "Last3Months", 5919 IsSelected = string.Compare(reqDateFrom, lastThreeMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0, 5920 Attributes = 5921 { 5922 {"data-fromMonth", lastThreeMonths.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5923 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5924 } 5925 }); 5926 5927 dateFilter.FieldOptionsList.Add(new FieldOption 5928 { 5929 Label = Translate("Last 12 Months"), 5930 Value = "Last12Months", 5931 IsSelected = string.Compare(reqDateFrom, lastTwelveMonths.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0 , 5932 Attributes = 5933 { 5934 {"data-fromMonth", lastTwelveMonths.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5935 {"data-toMonth", lastDayOfLastMonth.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5936 } 5937 }); 5938 5939 dateFilter.FieldOptionsList.Add(new FieldOption 5940 { 5941 Label = Translate("All"), 5942 Value = "All", 5943 IsSelected = reqDateFrom.IsNullOrEmpty() || string.Compare(reqDateFrom, SqlDateTime.MinValue.Value.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture), StringComparison.CurrentCultureIgnoreCase) == 0 , 5944 Attributes = 5945 { 5946 {"data-fromMonth", SqlDateTime.MinValue.Value.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)}, 5947 {"data-toMonth", SqlDateTime.MaxValue.Value.Date.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)} 5948 } 5949 }); 5950 5951 var stateFilter = new FieldSettings 5952 { 5953 Type = FieldType.Select, 5954 Id = "stateFilter", 5955 SystemName = "stateFilter", 5956 CssClass = "selectpicker", 5957 IncludeWrapper = true, 5958 WrapperCssClass = "col-xs-12 col-sm-3 noPadding pull-left", 5959 FieldOptionsList = new List<FieldOption>() 5960 }; 5961 5962 stateFilter.FirstHardcodedOptionLabel = Translate("Select State"); 5963 stateFilter.FirstHardcodedOptionValue = ""; 5964 5965 foreach (var state in Dynamicweb.Ecommerce.Orders.OrderState.GetAllOrderStates()) 5966 { 5967 if (state.Id != "OS1" && state.Id != "OS9" && state.Id != "OS11") 5968 { 5969 continue; 5970 } 5971 5972 stateFilter.FieldOptionsList.Add(new FieldOption() 5973 { 5974 Label = state.Name, 5975 Value = state.Id, 5976 IsSelected = string.Compare(reqStateFilter, state.Id, StringComparison.CurrentCultureIgnoreCase) == 0 5977 }); 5978 } 5979 5980 var searchBox = new FieldSettings 5981 { 5982 Type = FieldType.Search, 5983 Placeholder = Translate("Search"), 5984 Id = "searchData", 5985 WrapperCssClass = "col-xs-12 col-sm-6 noPaddingLeft", 5986 IncludeWrapper = true, 5987 SystemName = "SearchText", 5988 Value = Sanitize.Parameter("SearchText", ParameterType.LongText) 5989 }; 5990 5991 <form action="@SearchEngineFriendlyURLs.GetFriendlyUrl(searchOrdersPageId)" id="searchFormReports" class="col-xs-12 noPadding" method="post"> 5992 @RenderField(FieldSettings.CreateHiddenField("ViewPID", Pageview.CurrentParagraph.ID.ToString())) 5993 @RenderField(FieldSettings.CreateHiddenField("DWPagingPageNum", Sanitize.Parameter("DWPagingPageNum").IsNotNullOrEmpty() ? Sanitize.Parameter("DWPagingPageNum") : "1")) 5994 @RenderField(FieldSettings.CreateHiddenField("sortby", Sanitize.Parameter("sortby"))) 5995 @RenderField(FieldSettings.CreateHiddenField("sortorder", Sanitize.Parameter("sortorder"))) 5996 @foreach (string f in dropdownFilterFields) 5997 { 5998 @RenderField(FieldSettings.CreateHiddenField(f, Sanitize.Parameter(f, "[0-9][\f][\r][\n][,][.][-][@][#][!][ ]['][/][\"]"))) 5999 } 6000 6001 @RenderField(new FieldSettings() 6002 { 6003 Type = FieldType.Hidden, 6004 SystemName = "setPaidCommissions", 6005 Attributes = new Dictionary<string, string> 6006 { 6007 {"disabled", "disabled"} 6008 } 6009 }) 6010 @RenderField(FieldSettings.CreateHiddenField("startDate")) 6011 @RenderField(FieldSettings.CreateHiddenField("endDate")) 6012 @if (Pageview.Page.ID.Equals(GetPageIdByNavigationTag("CommissionsOnReports"))) 6013 { 6014 var totalCommissions = Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, reportsListLoop.Any() ? reportsListLoop.First().GetDouble("TotalCommission") : 0); 6015 <p class="col-xs-12 col-sm-6 noPadding pull-left">@Translate("Total Commissions in this time period:") <strong>@totalCommissions</strong></p> 6016 } 6017 @RenderBootstrapButton(new BootstrapButtonSettings 6018 { 6019 Id = "downloadDataList", 6020 CssClass = "btn-bg pull-right", 6021 Label = Translate("Download to Excel/CSV"), 6022 Attributes = new Dictionary<string, string>{ 6023 {"data-action", SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag(Pageview.Page.ID.Equals(GetPageIdByNavigationTag("OrdersOnReports")) ? "OrdersCSV" : "CommissionsCSV"))} 6024 }, 6025 Href = Dna.UrlServices.Helpers.BuildUri(Dna.UrlServices.Helpers.GetCurrentUrl(true, true), queryParameters).PathAndQuery 6026 }) 6027 6028 <div class="col-xs-12 noPadding dataListFilters generalMarginBottom"> 6029 <span class="col-xs-12 noPadding">@Translate("Date Filter")</span> 6030 @RenderField(dateFilter) 6031 @if (Pageview.Page.ID.Equals(GetPageIdByNavigationTag("CommissionsOnReports"))) 6032 { 6033 @RenderField(stateFilter) 6034 } 6035 <div class="col-xs-12 col-sm-6 noPadding text-right pull-right"> 6036 @RenderField(searchBox) 6037 @RenderBootstrapButton(new BootstrapButtonSettings {IconCssClass = "fa-search", ButtonType = BootstrapButtonSettings.BootstrapButtonType.Button}) 6038 </div> 6039 </div> 6040 </form> 6041 } 6042 6043 @helper RenderTabWithCommissionsList(List<LoopItem> reportsListLoop , string detailPageBase) 6044 { 6045 var excludedColumns = new string[] {"OrderSecret", "TotalCommission"}; 6046 6047 <table id="myOrdersTable" class="col-xs-12 noPadding text-left evenTable"> 6048 @RenderDataListTableHead(excludedColumns) 6049 <tbody> 6050 @foreach (var row in reportsListLoop) 6051 { 6052 var orderId = row.GetString("OrderID"); 6053 var orderSecret = row.GetString("OrderSecret"); 6054 var detailPage = string.Concat(detailPageBase, "?OrderId=", orderId, "&OrderSecret=", orderSecret); 6055 <tr> 6056 @foreach (var rowValue in row.GetLoop("Row").Where(c => !excludedColumns.Contains(c.GetString("Row.ColumnName")))) 6057 { 6058 var columnName = rowValue.GetString("Row.ColumnName"); 6059 <td data-th="@Translate(columnName)"> 6060 @if (columnName.Contains("Amount") || columnName.Contains("QualifyingItems") || columnName.Equals("Commission")) 6061 { 6062 @Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, rowValue.GetDouble("Row.Value")) 6063 } 6064 else if (columnName == "OrderID" && orderSecret.IsNotNullOrEmpty()) 6065 { 6066 <a href="@detailPage">@rowValue.GetString("Row.Value")</a> 6067 } 6068 else if (columnName == "PaidCommission") 6069 { 6070 @RenderField(new FieldSettings 6071 { 6072 Type = FieldType.Checkbox, 6073 Label = "&nbsp", 6074 IsChecked = rowValue.GetBoolean("Row.Value"), 6075 SystemName = string.Concat("PaidCommission", orderId), 6076 Value = orderId 6077 }) 6078 } 6079 else 6080 { 6081 switch (rowValue.GetValue("Row.Value").GetType().ToString()) 6082 { 6083 case "System.DateTime": 6084 @rowValue.GetDate("Row.Value").ToString("MM/dd/yyyy") 6085 break; 6086 case "System.Double": 6087 @rowValue.GetDouble("Row.Value") 6088 break; 6089 default: 6090 @rowValue.GetString("Row.Value") 6091 break; 6092 } 6093 } 6094 </td> 6095 } 6096 </tr> 6097 } 6098 </tbody> 6099 <tfoot> 6100 <tr> 6101 <td class="text-right" colspan="11"> 6102 @RenderField(new FieldSettings 6103 { 6104 Type = FieldType.Checkbox, 6105 Label = Translate("Toggle all"), 6106 SystemName = "TogglePaidCommission" 6107 }) 6108 @RenderBootstrapButton(new BootstrapButtonSettings 6109 { 6110 ButtonType = BootstrapButtonSettings.BootstrapButtonType.Button, 6111 Label = Translate("Apply"), 6112 Id = "setPaidCommissionsButton", 6113 CssClass = "btn-default" 6114 }) 6115 </td> 6116 </tr> 6117 </tfoot> 6118 </table> 6119 } 6120 6121 @helper RenderTabWithOrderReportsList(List<LoopItem> reportsListLoop ,string detailPageBase, string[] dropdownFilterFields = null) 6122 { 6123 var excludedColumns = new string[] {"OrderSecret"}; 6124 6125 <table id="myOrdersTable" class="col-xs-12 noPadding text-left evenTable"> 6126 @RenderDataListTableHead(excludedColumns, false, dropdownFilterFields) 6127 <tbody> 6128 @foreach (var row in reportsListLoop) 6129 { 6130 var orderId = row.GetString("OrderID"); 6131 var orderSecret = row.GetString("OrderSecret"); 6132 var detailPage = string.Concat(detailPageBase, "?OrderId=", orderId, "&OrderSecret=", orderSecret); 6133 <tr> 6134 @foreach (var rowValue in row.GetLoop("Row").Where(c => !excludedColumns.Contains(c.GetString("Row.ColumnName")))) 6135 { 6136 6137 var columnName = rowValue.GetString("Row.ColumnName"); 6138 var columnHeading = Translate(string.Concat("Data List ", columnName)); 6139 <td data-th="@columnHeading"> 6140 @if (columnName.Contains("Price")) 6141 { 6142 @Services.Currencies.Format(Dynamicweb.Ecommerce.Common.Context.Currency, rowValue.GetDouble("Row.Value")) 6143 } 6144 else if (columnName == "OrderID" && orderSecret.IsNotNullOrEmpty()) 6145 { 6146 <a href="@detailPage">@rowValue.GetString("Row.Value")</a> 6147 } 6148 else if (columnName == "OrderWeight") 6149 { 6150 <text> 6151 @string.Concat(rowValue.GetString("Row.Value"), " ", Dynamicweb.Configuration.SystemConfiguration.Instance.GetValue("/Globalsettings/Ecom/Unit/Weight")) 6152 </text> 6153 } 6154 else 6155 { 6156 switch (rowValue.GetValue("Row.Value").GetType().ToString()) 6157 { 6158 case "System.DateTime": 6159 if(rowValue.GetDate("Row.Value") != Convert.ToDateTime("01/01/0001 12:00:00 AM")) 6160 {@rowValue.GetDate("Row.Value").ToString("MM/dd/yyyy")} 6161 6162 6163 break; 6164 case "System.Double": 6165 @rowValue.GetDouble("Row.Value") 6166 break; 6167 default: 6168 @rowValue.GetString("Row.Value") 6169 break; 6170 } 6171 } 6172 </td> 6173 } 6174 </tr> 6175 } 6176 </tbody> 6177 </table> 6178 } 6179 6180 @helper RenderDataListTableHead(string[] excludedColumns = null, bool showActions = false, string[] dropdownFilterFields = null) 6181 { 6182 excludedColumns = excludedColumns ?? new string[0]; 6183 dropdownFilterFields = dropdownFilterFields ?? new string[0]; 6184 6185 <thead class="orderList"> 6186 <tr> 6187 @foreach (var column in GetLoop("Columns").Where(c => !excludedColumns.Contains(c.GetString("Column.Name")))) 6188 { 6189 var thAttributes = dropdownFilterFields.Contains(column.GetString("Column.Name")) ? string.Concat("data-filter=\"", column.GetString("Column.Name"), "\"") : "class=\"no-filter\""; 6190 <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> 6191 } 6192 @if(showActions) 6193 { 6194 <th>@RenderTableHeading(Translate("Actions"))</th> 6195 } 6196 </tr> 6197 </thead> 6198 } 6199 } 6200 @functions 6201 { 6202 6203 public string GetDistinctFilterValues() 6204 { 6205 if (!Pageview.Page.ID.Equals(GetPageIdByNavigationTag("OrdersOnReports"))) 6206 return string.Empty; 6207 { 6208 } 6209 6210 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]; 6211 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]; 6212 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]; 6213 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]; 6214 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]; 6215 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]; 6216 var reqSearchText = Sanitize.Parameter("SearchText", ParameterType.LongText); 6217 var reqDateFrom = Sanitize.Parameter("startdate", ParameterType.Date); 6218 var reqDateTo = Sanitize.Parameter("endDate", ParameterType.Date); 6219 reqDateFrom = reqDateFrom.IsNotNullOrEmpty() ? reqDateFrom : "01/01/1753"; 6220 reqDateTo = reqDateTo.IsNotNullOrEmpty() ? reqDateTo : "12/31/9999"; 6221 6222 var results = new Dictionary<string, Dictionary<string, bool>>(); 6223 results.Add("Status", new Dictionary<string, bool>()); 6224 results.Add("DealerName", new Dictionary<string, bool>()); 6225 results.Add("Backordered", new Dictionary<string, bool>()); 6226 results.Add("ShippingMethod", new Dictionary<string, bool>()); 6227 results.Add("DealerState", new Dictionary<string, bool>()); 6228 results.Add("SalesRep", new Dictionary<string, bool>()); 6229 6230 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 "+ 6231 "JOIN EcomOrderStates states ON o.OrderStateID = states.OrderStateID "+ 6232 "JOIN AccessUser customer ON customer.AccessUserCustomerNumber = o.OrderCustomerNumber AND ISNULL(customer.AccessUser_SalesRepId, '') <> '' " + 6233 "LEFT OUTER JOIN AccessUser loginUser ON loginUser.AccessUserID = o.OrderSecondaryUserID " + 6234 "JOIN AccessUser salesRep ON customer.AccessUser_SalesRepId=salesRep.AccessUser_SalesRepSalesRepId AND ISNULL(customer.AccessUser_SalesRepId, '') <> '' "+ 6235 "WHERE o.OrderDate IS NOT NULL " + 6236 "AND o.OrderIsLedgerEntry=0 " + 6237 "AND o.OrderDeleted=0 " + 6238 "AND customer.AccessUser_CustomerType IN ('B2B','B2BLegEligible','GLMP') " + 6239 "AND o.OrderDate >= CONVERT(datetime, '" + reqDateFrom + "', 101) " + 6240 "AND o.OrderDate <= CONVERT(datetime, '" + reqDateTo + "', 101) " + 6241 "AND (" + 6242 "states.OrderStateName LIKE '%" + reqSearchText + "%' " + 6243 "OR customer.AccessUser_SalesRepId LIKE '%" + reqSearchText + "%' " + 6244 "OR o.OrderShippingMethod LIKE '%" + reqSearchText + "%' " + 6245 "OR o.OrderCustomerName LIKE '%" + reqSearchText + "%' " + 6246 "OR o.OrderID LIKE '%" + reqSearchText + "%' " + 6247 "OR loginUser.AccessUserName LIKE '%" + reqSearchText + "%' " + 6248 "OR o.PONumber LIKE '%" + reqSearchText + "%'" + 6249 ")"); 6250 6251 while (distinctFilterValues.Read()) 6252 { 6253 var status = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["Status"].ToString().ToLowerInvariant()).Replace("'", "''"); 6254 var dealerName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["DealerName"].ToString().ToLowerInvariant()).Replace("'", "''"); 6255 var backordered = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["Backordered"].ToString().ToLowerInvariant()).Replace("'", "''"); 6256 var shippingMethod = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["ShippingMethod"].ToString().ToLowerInvariant()).Replace("'", "''"); 6257 var dealerState = distinctFilterValues["DealerState"].ToString().Replace("'", "''"); 6258 var salesRep = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(distinctFilterValues["SalesRep"].ToString().ToLowerInvariant()).Replace("'", "''"); 6259 6260 if (!results["Status"].ContainsKey(status) && status.IsNotNullOrEmpty()) 6261 { 6262 results["Status"].Add(status, (!submitedStatus.Any() || submitedStatus.Contains(status))); 6263 } 6264 6265 if (!results["DealerName"].ContainsKey(dealerName) && dealerName.IsNotNullOrEmpty()) 6266 { 6267 results["DealerName"].Add(dealerName, (!submitedDealerName.Any() || submitedDealerName.Contains(dealerName))); 6268 } 6269 6270 if (!results["Backordered"].ContainsKey(backordered) && backordered.IsNotNullOrEmpty()) 6271 { 6272 results["Backordered"].Add(backordered, (!submitedBackordered.Any() || submitedBackordered.Contains(backordered))); 6273 } 6274 6275 if (!results["ShippingMethod"].ContainsKey(shippingMethod) && shippingMethod.IsNotNullOrEmpty()) 6276 { 6277 results["ShippingMethod"].Add(shippingMethod, (!submitedShippingMethod.Any() || submitedShippingMethod.Contains(shippingMethod))); 6278 } 6279 6280 if (!results["DealerState"].ContainsKey(dealerState) && dealerState.IsNotNullOrEmpty()) 6281 { 6282 results["DealerState"].Add(dealerState, (!submitedDealerState.Any() || submitedDealerState.Contains(dealerState))); 6283 } 6284 6285 if (!results["SalesRep"].ContainsKey(salesRep) && salesRep.IsNotNullOrEmpty()) 6286 { 6287 results["SalesRep"].Add(salesRep, (!submitedSalesRep.Any() || submitedSalesRep.Contains(salesRep))); 6288 } 6289 } 6290 6291 return new JavaScriptSerializer().Serialize(results); 6292 } 6293 } 6294 @{ 6295 var ordersLoop = GetLoop("Rows"); 6296 var editingOrders = ordersLoop.Where(o => o.GetString("IsEditing").Equals("true", StringComparison.InvariantCultureIgnoreCase)).ToList(); 6297 var noOrdersMessage = Pageview.Page.ID.Equals(GetPageIdByNavigationTag("openOrders")) ? Translate("No open orders found") : Translate("No processed orders found"); 6298 var viewOrderPageId = GetPageIdByNavigationTag("ViewOrder"); 6299 var sendOrderPage = GetPageIdByNavigationTag("SendOrder"); 6300 var detailPageBase = SearchEngineFriendlyURLs.GetFriendlyUrl(viewOrderPageId); 6301 if (editingOrders.Any()) 6302 { 6303 foreach (var order in editingOrders) 6304 { 6305 CancelOrder(orderService.GetById(order.GetString("OrderID"))); 6306 } 6307 6308 <script> 6309 document.body.style.display = "none"; 6310 window.location.href = window.location.href; 6311 </script> 6312 } 6313 6314 <div id="tabsContainer" class="col-xs-12 noPadding tabsOrdersListContainer"> 6315 @RenderNavigation(new 6316 { 6317 StartLevel = 4, 6318 EndLevel = 4, 6319 Template = "liClean.xslt", 6320 ID = "reportsMenu", 6321 }) 6322 @RenderTabWithOrdersList(ordersLoop,noOrdersMessage,sendOrderPage,detailPageBase) 6323 </div> 6324 6325 } 6326 @SnippetStart("jsVariables") 6327 var successMessage = ('@Translate("Order email was sent successfully.")'); 6328 var errorMessage = ('@Translate("Something went wrong")'); 6329 @SnippetEnd("jsVariables") 6330 @SnippetStart("jsOnLoad") 6331 onLoadOrderList("@Translate("Items have been added to the cart")", "@("CCResend" + GetParagraphIdFromCc() + "=successfully")"); 6332 @SnippetEnd("jsOnLoad")