@inherits ViewModelTemplate @using Dynamicweb.Rendering @using Dynamicweb.Ecommerce.ProductCatalog @using Dynamicweb.Core.Encoders @using Dynamicweb.Environment @{ var productList = Model.Products; string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); bool anonymousUser = Pageview.User == null; bool isErpConnectionDown = !Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHideAddToCart") && isErpConnectionDown; bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown; string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); if (!url.Contains("LayoutTemplate")) { url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; } string iconPath = "/Files/icons/"; string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); string selectedDisplayGroups = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["SelectedDisplayGroups"]) ? Dynamicweb.Context.Current.Request.Form["SelectedDisplayGroups"].ToString() : ""; List selectedDisplayGroupsList = selectedDisplayGroups != null ? selectedDisplayGroups.Split(',').ToList() : new List(); //Collect the titles for all available fields List fieldsHeaders = new List(); foreach (var product in productList) { foreach (var selection in selectedDisplayGroupsList) { foreach (CategoryFieldViewModel group in product.FieldDisplayGroups.Values) { if (selection.ToString() == group.Id) { foreach (var field in group.Fields) { if (!fieldsHeaders.Contains(field.Value.Name)) { bool noValues = false; if (field.Value.Value.GetType() == typeof(System.Collections.Generic.List)) { System.Collections.Generic.List values = field.Value.Value as System.Collections.Generic.List; noValues = values.Count > 0 ? false : true; } else if (string.IsNullOrEmpty(field.Value.Value.ToString())) { noValues = true; } if (!noValues) { fieldsHeaders.Add(field.Value.Name); } } } } } } } //Check if there are any facet and count the amount of selected facets bool facetsFound = false; int selectedFacetsCount = 0; if (Model.FacetGroups != null) { foreach (FacetGroupViewModel facetGroup in Model.FacetGroups) { foreach (FacetViewModel facet in facetGroup.Facets) { if (facet.Options.Count() > 0) { facetsFound = true; foreach (FacetOptionViewModel option in facet.Options) { if (option.Selected) { selectedFacetsCount++; } } } } } } //Map the data string selectedFacetsLabel = selectedFacetsCount > 0 ? "(" + selectedFacetsCount + ")" : ""; int totalGroups = Model.FacetGroups.Count(); int pageSizeSetting = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["PageSizeSetting"]) ? Convert.ToInt32(Dynamicweb.Context.Current.Request.Form["PageSizeSetting"].ToString()) : 10; string sourceType = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["SourceType"]) ? Dynamicweb.Context.Current.Request.Form["SourceType"].ToString() : "variants"; string requestType = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["RequestType"]) ? Dynamicweb.Context.Current.Request.Form["RequestType"].ToString() : ""; string title = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["Title"]) ? Dynamicweb.Context.Current.Request.Form["Title"].ToString() : ""; string mainProductId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["MainProductID"]) ? Dynamicweb.Context.Current.Request.Form["MainProductID"].ToString() : ""; string paragraphID = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["ParagraphID"]) ? Dynamicweb.Context.Current.Request.Form["ParagraphID"].ToString() : ""; string servicePageId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["ID"]) ? Dynamicweb.Context.Current.Request.Form["ID"].ToString() : ""; bool hideTitle = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["HideTitle"]) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form["HideTitle"].ToString()) : false; bool hideImage = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["HideImage"]) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form["HideImage"].ToString()) : false; bool hideProductNumber = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["HideProductNumber"]) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form["HideProductNumber"].ToString()) : false; bool hideProductName = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["HideProductName"]) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form["HideProductName"].ToString()) : false; bool hideStock = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["HideStock"]) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form["HideStock"].ToString()) : false; bool quantitySelector = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["QuantitySelector"]) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form["QuantitySelector"].ToString()) : false; string addToCartColWidth = quantitySelector ? "160" : "60"; bool hideFilters = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["HideFilters"]) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.Form["HideFilters"].ToString()) : false; string saleBadgeType = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("SaleBadgeType")) ? Dynamicweb.Context.Current.Request.Form.Get("SaleBadgeType") : ""; string saleBadgeCssClassName = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("SaleBadgeCssClassName")) ? Dynamicweb.Context.Current.Request.Form.Get("SaleBadgeCssClassName") : ""; string newBadgeCssClassName = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("NewBadgeCssClassName")) ? Dynamicweb.Context.Current.Request.Form.Get("NewBadgeCssClassName") : ""; int newPublicationDays = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("NewPublicationDays")) ? Convert.ToInt32(Dynamicweb.Context.Current.Request.Form.Get("NewPublicationDays")) : 0; string campaignBadgesValues = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("CampaignBadgesValues")) ? Dynamicweb.Context.Current.Request.Form.Get("CampaignBadgesValues") : ""; var badgeParms = new Dictionary(); badgeParms.Add("saleBadgeType", saleBadgeType); badgeParms.Add("saleBadgeCssClassName", saleBadgeCssClassName); badgeParms.Add("newBadgeCssClassName", newBadgeCssClassName); badgeParms.Add("campaignBadgesValues", campaignBadgesValues); badgeParms.Add("newPublicationDays", newPublicationDays); bool saleBadgeEnabled = !string.IsNullOrWhiteSpace(saleBadgeCssClassName) && saleBadgeCssClassName != "none" ? true : false; bool newBadgeEnabled = !string.IsNullOrWhiteSpace(newBadgeCssClassName) && newBadgeCssClassName != "none" ? true : false; string theme = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["Theme"]) ? Dynamicweb.Context.Current.Request.Form["Theme"].ToString() : ""; string modalTheme = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["ModalTheme"]) ? Dynamicweb.Context.Current.Request.Form["ModalTheme"].ToString() : "theme light"; string titleFontSize = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["TitleFontSize"]) ? Dynamicweb.Context.Current.Request.Form["TitleFontSize"].ToString() : ""; string contentPadding = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["ContentPadding"]) ? Dynamicweb.Context.Current.Request.Form["ContentPadding"].ToString() : ""; //Create group id collection and products id collection strings string groupId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["GroupId"]) ? Dynamicweb.Context.Current.Request.Form["GroupId"].ToString() : ""; string productIds = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["MainProductID"]) ? Dynamicweb.Context.Current.Request.Form["MainProductID"].ToString() : ""; string contextCart = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form["OrderContext"]) ? Dynamicweb.Context.Current.Request.Form["OrderContext"].ToString() : ""; bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; string googleAnalyticsTrackingID = Pageview.AreaSettings.GetString("GoogleAnalyticsTrackingID"); string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); } @if (productList.Count > 0 && requestType != "UpdateFacets") { //The form that defines what should be rendered
@if (!string.IsNullOrEmpty(contextCart)) { } @if (isLazyLoadingForProductInfoEnabled) { } @*--- VARIANTS ---*@ @if (sourceType == "variants") { } @*--- MOST SOLD ---*@ @if (sourceType == "most-sold") { } @*--- TRENDING ---*@ @if (sourceType == "trending") { } @*--- LATEST ---*@ @if (sourceType == "latest") { } @*--- FREQUENTLY BOUGHT ---*@ @if (sourceType == "frequently") { } @*--- RELATED PRODUCTS ---*@ @if (sourceType == "related-products") { } @if (sourceType != "variants") { } else { } @if (campaignBadgesValues != "") { } @if (facetsFound && !hideFilters) { }
//The products list table
@if (!string.IsNullOrEmpty(title) && !hideTitle) {

@title

} @if (facetsFound && !hideFilters) { }
@if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) { string itemVariant = string.Empty; } @if (!hideImage) { } @if (!hideProductNumber) { } @if (!hideProductName) { } @foreach (var header in fieldsHeaders) { } @if (!hideStock) { } @if (!hidePrice) { } @if (!hideAddToCart) { } @foreach (var product in productList) { string image = product.DefaultImage.Value; image = $"/Admin/Public/GetImage.ashx?image={image}&width=30&format=webp"; DateTime createdDate = product.Created.Value; bool showBadges = saleBadgeEnabled && product.Discount.Price != 0 ? true : false; showBadges = (newBadgeEnabled && newPublicationDays == 0) || (newBadgeEnabled && (createdDate.AddDays(newPublicationDays) > DateTime.Now)) ? true : showBadges; showBadges = !string.IsNullOrEmpty(campaignBadgesValues) ? true : showBadges; List categories = new List(); foreach (var selection in selectedDisplayGroupsList) { foreach (CategoryFieldViewModel group in product.FieldDisplayGroups.Values) { if (selection.ToString() == group.Id) { categories.Add(group); } } } @if (!hideImage) { } @if (!hideProductNumber) { } @if (!hideProductName) { } @foreach (string fieldCell in fieldsHeaders) { FieldValueViewModel fieldValue = new FieldValueViewModel(); bool fieldFound = false; foreach (CategoryFieldViewModel category in categories) { foreach (var field in category.Fields) { bool noValues = false; if (field.Value.Value.GetType() == typeof(System.Collections.Generic.List)) { System.Collections.Generic.List values = field.Value.Value as System.Collections.Generic.List; noValues = values.Count > 0 ? false : true; } else if (string.IsNullOrEmpty(field.Value.Value.ToString())) { noValues = true; } if (!noValues) { string fieldName = field.Value.Name; if (fieldName == fieldCell) { fieldValue = field.Value; fieldFound = true; } } } } if (fieldFound) { } else { } } @if (!hideStock) { } @if (!hidePrice) { } @if (!hideAddToCart) { bool isDiscontinued = product.Discontinued; bool IsNeverOutOfStock = product.NeverOutOfstock; string disableAddToCart = (product.StockLevel <= 0) ? "disabled" : ""; disableAddToCart = isDiscontinued ? " disabled" : disableAddToCart; disableAddToCart = IsNeverOutOfStock ? "" : disableAddToCart; string minQty = product.PurchaseMinimumQuantity != 1 ? "min=\"" + product.PurchaseMinimumQuantity.ToString() + "\"" : "min=\"1\""; string stepQty = product.PurchaseQuantityStep > 1 ? product.PurchaseQuantityStep.ToString() : "1"; string valueQty = product.PurchaseMinimumQuantity > product.PurchaseQuantityStep ? product.PurchaseMinimumQuantity.ToString() : stepQty; string qtyValidCheck = stepQty != "1" ? "onkeyup=\"swift.Cart.QuantityValidate(event)\"" : ""; } }
 #@Translate("Product")@header@Translate("Stock")@Translate("Price")@Translate("Qty")
@product.Number @if (!string.IsNullOrEmpty(product.VariantName)) {
@product.Name - @product.VariantName
} else { @product.Name } @if (showBadges) {
@RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms)
}
@RenderFieldValue(fieldValue)  @if (product.StockLevel > 0) { @Translate("In stock") } else { @Translate("Out of stock") }
@if (showPricesWithVat == "false" && !neverShowVat) { if (product.Price.Price != product.PriceBeforeDiscount.Price) { @product.PriceBeforeDiscount.PriceWithoutVatFormatted } } else { if (product.Price.Price != product.PriceBeforeDiscount.Price) { @product.PriceBeforeDiscount.PriceFormatted } } @if (showPricesWithVat == "false" && !neverShowVat) { @product.Price.PriceWithoutVatFormatted } else { @product.Price.PriceFormatted }
@if (showPricesWithVat == "false" && !neverShowVat) { @product.Price.PriceWithVatFormatted @Translate("Incl. VAT") }
@if (!string.IsNullOrEmpty(contextCart)) { } @if (!string.IsNullOrEmpty(product.VariantId)) { } @if (quantitySelector) {
if (stepQty != "1") {
@Translate("Please select a quantity that is dividable by") @stepQty
} } else { }
@if (Model.PageCount > 1) { int totalProducts = Model.TotalProductsCount; int pageSize = Model.PageSize; pageSize += pageSizeSetting;
@Model.PageSize @Translate("out of") @totalProducts
}
} @helper RenderFieldValue(FieldValueViewModel field) { string fieldValue = field?.Value != null ? field.Value.ToString() : ""; fieldValue = fieldValue == "False" ? Translate("No") : fieldValue; fieldValue = fieldValue == "True" ? Translate("Yes") : fieldValue; bool isColor = false; if (field.Value.GetType() == typeof(System.Collections.Generic.List)) { int valueCount = 0; System.Collections.Generic.List values = field.Value as System.Collections.Generic.List; int totalValues = values.Count; foreach (FieldOptionValueViewModel option in values) { if (!string.IsNullOrEmpty(option.Value)) { if (option.Value.Substring(0,1) == "#") { isColor = true; } } if (!isColor) { @option.Name } else { } if (valueCount != totalValues && valueCount < (totalValues - 1)) { if (isColor) { } else { , } } valueCount++; } } else if (fieldValue != "") { if (fieldValue.Substring(0,1) == "#") { isColor = true; } if (!isColor) { @fieldValue } else { } } } @* Deliver only the facets update *@ @if (requestType == "UpdateFacets" && facetsFound) { @RenderFacets() } @* Filters *@ @helper RenderFacets() { foreach (FacetGroupViewModel facetGroup in Model.FacetGroups) { foreach (FacetViewModel facet in facetGroup.Facets) { if (facet.Options.Count() > 0) {

@facet.Name

@foreach (FacetOptionViewModel facetOption in facet.Options) { string renderType = facet.RenderType; if (renderType == "Colors") { @RenderColorOption(facet, facetOption) } else { @RenderCheckboxOption(facet, facetOption) } }
} } } } @helper RenderCheckboxOption(FacetViewModel facet, FacetOptionViewModel facetOption) { string facetLabel = HtmlEncoder.HtmlEncode(facetOption.Label); string disabled = facetOption.Count <= 0 ? "disabled" : ""; string selected = facetOption.Selected ? "checked" : ""; if (facetLabel.ToLower() == "true") { facetLabel = Translate("Yes"); } if (facetLabel.ToLower() == "false") { facetLabel = Translate("No"); } } @helper RenderColorOption(FacetViewModel facet, FacetOptionViewModel facetOption) { string facetLabel = HtmlEncoder.HtmlEncode(facetOption.Label); string disabled = facetOption.Count <= 0 ? "disabled" : ""; string selected = facetOption.Selected ? "checked" : ""; string image = facetOption.Value; string colorCode = facetOption.Value; var variantOption = Dynamicweb.Ecommerce.Services.VariantOptions.GetVariantOption(facetOption.Value.ToString(), Dynamicweb.Ecommerce.Common.Context.LanguageID); if (variantOption != null) { image = variantOption.LargeImage; colorCode = variantOption.Color; }
@if (colorCode.Contains("#")) { } else { }
}