Webiant Logo Webiant Logo
  1. No results found.

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

_ProductAddAttributes.cshtml

@model IList

@using System.Text
@using Nop.Core.Domain.Catalog;
@using Nop.Services.Catalog;
@inject CatalogSettings catalogSettings

@if (Model.Count > 0)
{
    //dynamic update support
    var attributeChangeScriptsBuilder = new StringBuilder();
    var productId = Convert.ToInt32(ViewData["productId"]);
    var attributesHaveConditions = Model.Any(a => a.HasCondition);
    var attributeChangeHandlerFuncName = $"attribute_change_handler_{productId}";

    var getAttributeValueName = new Func((attributeValue) =>
        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);

    
@foreach (var attribute in Model) {
@{ var controlId = $"{NopCatalogDefaults.ProductAttributePrefix}{attribute.Id}"; var textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name; }
@switch (attribute.AttributeControlType) { case AttributeControlType.DropdownList: { foreach (var attributeValue in attribute.Values.Where(value => value.CustomerEntersQty)) { } } break; case AttributeControlType.RadioList: case AttributeControlType.ColorSquares: case AttributeControlType.ImageSquares: { foreach (var attributeValue in attribute.Values) {
@if (attributeValue.CustomerEntersQty) { }
} } break; case AttributeControlType.Checkboxes: case AttributeControlType.ReadonlyCheckboxes: { foreach (var attributeValue in attribute.Values) {
@if (attributeValue.CustomerEntersQty) { }
} } break; case AttributeControlType.TextBox: { } break; case AttributeControlType.MultilineTextbox: { } break; case AttributeControlType.Datepicker: { } break; case AttributeControlType.FileUpload: { @* register CSS and JS *@ //ex. ['jpg', 'jpeg', 'png', 'gif'] or [] var allowedFileExtensions = attribute.AllowedFileExtensions != null && attribute.AllowedFileExtensions.Any() ? string.Join(", ", attribute.AllowedFileExtensions.Select(x => "'" + x.Trim() + "'").ToList()) : null; @*fine uploader container*@
@*fine uploader template (keep it synchronized to \Content\fineuploader\templates\default.html)*@
} break; }
@if (attribute.IsRequired) { }
} @*generate change event script*@ @foreach (var attribute in Model) { var controlId = $"{NopCatalogDefaults.ProductAttributePrefix}{attribute.Id}"; switch (attribute.AttributeControlType) { case AttributeControlType.DropdownList: { attributeChangeScriptsBuilder.AppendFormat("$('#{0}').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}').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}').click(function(){{{2}();}});\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName); } } break; default: break; } foreach (var attributeValue in attribute.Values.Where(value => value.CustomerEntersQty)) { attributeChangeScriptsBuilder.AppendFormat("$('#{0}_{1}_qty').on('input propertychange paste', function(){{{2}();}});\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName); } } @*render scripts*@
}