@model SkyArtShop.Models.Product @{ ViewData["Title"] = Model.Name; } @if (Model.Images != null && Model.Images.Count > 0) { @for (int i = 0; i < Model.Images.Count; i++) { var image = Model.Images[i]; var isFirst = i == 0; } } else if (!string.IsNullOrEmpty(Model.ImageUrl)) { } else { } Click to view full size @{ var mainImageSrc = Model.Images != null && Model.Images.Count > 0 ? Model.Images[0] : (!string.IsNullOrEmpty(Model.ImageUrl) ? Model.ImageUrl : "/assets/images/placeholder.jpg"); } @Model.Name @if (!string.IsNullOrEmpty(Model.ShortDescription)) { @Model.ShortDescription } @if (!string.IsNullOrEmpty(Model.SKU)) { SKU: @Model.SKU } else if (!string.IsNullOrEmpty(Model.Category)) { SKU: @Model.Category.ToUpper().Replace(" ","")@Model.Id?.Substring(Model.Id.Length - 4) } @{ var rating = Model.AverageRating > 0 ? Model.AverageRating : 5.0; var fullStars = (int)Math.Floor(rating); var hasHalfStar = (rating - fullStars) >= 0.5; var emptyStars = 5 - fullStars - (hasHalfStar ? 1 : 0); } @for (int i = 0; i < fullStars; i++) { } @if (hasHalfStar) { } @for (int i = 0; i < emptyStars; i++) { } (@Model.TotalReviews review@(Model.TotalReviews != 1 ? "s" : "")) @if (Model.UnitsSold > 0) { @Model.UnitsSold sold } Price: $@Model.Price.ToString("F2") @if (Model.StockQuantity > 0) { In stock (@Model.StockQuantity+ units), ready to be shipped } else { @if (Model.StockQuantity > 0) { Add to Cart Add to Wishlist } else { Out of Stock } Out of stock } Quantity: @if (Model.StockQuantity > 0) { (@Model.StockQuantity available) } @if (Model.StockQuantity > 0) { Add to Cart Add to Wishlist } else { Out of Stock } @{ var hasVariants = Model.Variants != null && Model.Variants.Any(v => v.IsAvailable && v.Images != null && v.Images.Any()); var hasLegacyColors = (Model.Colors != null && Model.Colors.Any()) || !string.IsNullOrEmpty(Model.Color); if (hasVariants && Model.Variants != null) { // New variant system - filter only available variants with images var availableVariants = Model.Variants.Where(v => v.IsAvailable && v.Images != null && v.Images.Any()).ToList(); Select Color: Choose a color @foreach (var variant in availableVariants) { var variantJson = System.Text.Json.JsonSerializer.Serialize(new { colorName = variant.ColorName, colorHex = variant.ColorHex, images = variant.Images, stock = variant.StockQuantity, priceAdjust = variant.PriceAdjustment, sku = variant.SKU }); @variant.ColorName @if (variant.StockQuantity <= 5 && variant.StockQuantity > 0) { Only @variant.StockQuantity left } @if (variant.StockQuantity == 0) { Out of Stock } } } @* Legacy color system removed - all products should use Variants *@ } @if (!string.IsNullOrEmpty(Model.Description)) { Description @Html.Raw(Model.Description) See More } @if (ViewBag.RelatedProducts != null && ViewBag.RelatedProducts.Count > 0) { You May Also Like Based on what customers are viewing @foreach (var relatedProduct in ViewBag.RelatedProducts) { @relatedProduct.Name @if (!string.IsNullOrEmpty(relatedProduct.Color)) { @relatedProduct.Color } @Html.Raw(relatedProduct.ShortDescription ?? relatedProduct.Description) $@relatedProduct.Price.ToString("F2") } Browse More @Model.Category Products } else { Explore Our Collection Browse @Model.Category } @section Scripts { }
@Model.ShortDescription
Based on what customers are viewing
$@relatedProduct.Price.ToString("F2")