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