/// <summary> /// Sets currently valid stock information for render. /// </summary> private void SetStockInformation() { var selectedVariant = SelectedVariant; var selectedSKU = (selectedVariant != null) ? selectedVariant.Variant : SKU; // Used in listing. if (!UsedInProductDetail) { switch (selectedSKU.SKUTrackInventory) { case TrackInventoryTypeEnum.ByProduct: RenderStockInformation(selectedSKU.SKUAvailableItems > 0); break; case TrackInventoryTypeEnum.ByVariants: RenderStockInformation(Variants.Exists(variant => variant.Variant.SKUAvailableItems > 0)); break; default: RenderStockInformation(true); break; } } // Used in product detail. else { // Sku or variant is disabled or variant from given options does not exist. if (!selectedSKU.SKUEnabled || ((SelectedVariant == null) && (Variants.Count != 0))) { lblStockValue.Attributes.Remove("class"); lblStockValue.Attributes.Add("class", "stock unavailable"); lblStockValue.Text = GetString("com.variant.notavailable"); } else { RenderStockInformation((selectedSKU.SKUTrackInventory == TrackInventoryTypeEnum.Disabled) || (selectedSKU.SKUAvailableItems > 0)); } } }