Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

_ProductAttributes.cshtml

@model ProductDetailsModel
@using Nop.Core
@using Nop.Core.Domain.Catalog
@using Nop.Core.Domain.Media
@using System.Text
@using Nop.Services.Catalog
@using Nop.Services.Media
@inject IDownloadService downloadService
@inject CatalogSettings catalogSettings
@if (Model.ProductAttributes.Count > 0)
{
    
@foreach (var attribute in Model.ProductAttributes) { var controlId = $"{NopCatalogDefaults.ProductAttributePrefix}{attribute.Id}"; var textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name;
@if (attribute.IsRequired) { * } @if (!string.IsNullOrEmpty(attribute.Description)) {
@Html.Raw(attribute.Description)
}
@switch (attribute.AttributeControlType) { case AttributeControlType.DropdownList: { foreach (var attributeValue in attribute.Values.Where(value => value.CustomerEntersQty)) { } } break; case AttributeControlType.RadioList: {
    @foreach (var attributeValue in attribute.Values) { var attributeName = string.IsNullOrEmpty(attributeValue.PriceAdjustment) ? attributeValue.Name : T("Products.ProductAttributes.PriceAdjustment", attributeValue.Name, attributeValue.PriceAdjustment, attributeValue.CustomerEntersQty ? T("Products.ProductAttributes.PriceAdjustment.PerItem").Text : string.Empty).Text;
  • value.CustomerEntersQty) ? Html.Raw($"onclick=\"showHideRadioQuantity('{controlId}')\"") : null) /> @if (attributeValue.CustomerEntersQty) { }
  • }
} break; case AttributeControlType.Checkboxes: case AttributeControlType.ReadonlyCheckboxes: {
    @foreach (var attributeValue in attribute.Values) { var attributeName = string.IsNullOrEmpty(attributeValue.PriceAdjustment) ? attributeValue.Name : T("Products.ProductAttributes.PriceAdjustment", attributeValue.Name, attributeValue.PriceAdjustment, attributeValue.CustomerEntersQty ? T("Products.ProductAttributes.PriceAdjustment.PerItem").Text : string.Empty).Text;
  • @if (attributeValue.CustomerEntersQty) { }
  • }
} break; case AttributeControlType.TextBox: { } break; case AttributeControlType.MultilineTextbox: { } break; case AttributeControlType.Datepicker: { } break; case AttributeControlType.FileUpload: { Download download = null; if (!string.IsNullOrEmpty(attribute.DefaultValue)) { download = await downloadService.GetDownloadByGuidAsync(new Guid(attribute.DefaultValue)); } @* register CSS and JS *@ //ex. ['jpg', 'jpeg', 'png', 'gif'] or [] var allowedFileExtensions = string.Join(", ", attribute.AllowedFileExtensions.Select(x => "'" + x.Trim() + "'").ToList()); if (download != null) { } else { } @*fine uploader container*@
@*fine uploader template (keep it synchronized to \Content\fineuploader\templates\default.html)*@ } break; case AttributeControlType.ColorSquares: {
    @foreach (var attributeValue in attribute.Values) { var attributeName = string.IsNullOrEmpty(attributeValue.PriceAdjustment) ? attributeValue.Name : T("Products.ProductAttributes.PriceAdjustment", attributeValue.Name, attributeValue.PriceAdjustment, string.Empty).Text;
  • @T("Products.ProductAttributes.NotAvailable")
  • }
foreach (var attributeValue in attribute.Values.Where(value => value.CustomerEntersQty)) { } } break; case AttributeControlType.ImageSquares: {
    @foreach (var attributeValue in attribute.Values) { var attributeName = string.IsNullOrEmpty(attributeValue.PriceAdjustment) ? attributeValue.Name : T("Products.ProductAttributes.PriceAdjustment", attributeValue.Name, attributeValue.PriceAdjustment, string.Empty).Text;
  • @attributeName
    @attributeName
    @T("Products.ProductAttributes.NotAvailable")
  • }
foreach (var attributeValue in attribute.Values.Where(value => value.CustomerEntersQty)) { } } break; }
}
if (Model.AllowAddingOnlyExistingAttributeCombinations && catalogSettings.AttributeValueOutOfStockDisplayType == AttributeValueOutOfStockDisplayType.Disable) { } //dynamic update support var attributesHaveConditions = Model.ProductAttributes.Any(x => x.HasCondition); var attributesHaveAssociatedPictures = Model.ProductAttributes.Any(x => x.ProductId > 0); var attributeChangeScriptsBuilder = new StringBuilder(); var attributeChangeHandlerFuncName = $"attribute_change_handler_{Model.Id}"; if (catalogSettings.AjaxProcessAttributeChange) { if (Model.AllowAddingOnlyExistingAttributeCombinations && catalogSettings.AttributeValueOutOfStockDisplayType == AttributeValueOutOfStockDisplayType.Disable) { } else { //generate change event script foreach (var attribute in Model.ProductAttributes) { var controlId = $"{NopCatalogDefaults.ProductAttributePrefix}{attribute.Id}"; switch (attribute.AttributeControlType) { case AttributeControlType.DropdownList: { attributeChangeScriptsBuilder.AppendFormat("$('#{0}').on('change', function(){{{1}();}});\n", controlId, attributeChangeHandlerFuncName); } break; case AttributeControlType.RadioList: case AttributeControlType.ColorSquares: case AttributeControlType.ImageSquares: { foreach (var attributeValue in attribute.Values) { attributeChangeScriptsBuilder.AppendFormat("$('#{0}_{1}').on('click', function(){{{2}();}});\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName); } } break; case AttributeControlType.Checkboxes: case AttributeControlType.ReadonlyCheckboxes: { foreach (var attributeValue in attribute.Values) { attributeChangeScriptsBuilder.AppendFormat("$('#{0}_{1}').on('click', function(){{{2}();}});\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName); } } break; default: break; } } } foreach (var attribute in Model.ProductAttributes) { foreach (var attributeValue in attribute.Values.Where(value => value.CustomerEntersQty)) { var controlId = $"{NopCatalogDefaults.ProductAttributePrefix}{attribute.Id}"; attributeChangeScriptsBuilder.AppendFormat("$('#{0}_{1}_qty').on('input propertychange paste', function(){{{2}();}});\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName); } } //render scripts //almost the same implementation is used in the \Views\Product\_RentalInfo.cshtml file } }