Hello Victor,
Do you have a version that works with 3.4?
public bool isAvailable { get; set; }
foreach (var pvaValue in pvaValues)
{
//values
/*Dont show when out of stock*/
bool isAvailable = true;
bool foundCombination = false;
var allCombinations = _productAttributeService.GetAllProductVariantAttributeCombinations(product.Id);
foreach (var combination in allCombinations)
{
var attributeValues = _productAttributeParser.ParseProductVariantAttributeValues(combination.AttributesXml);
foreach (var value in attributeValues)
{
if (value.Id == pvaValue.Id)
{
if (combination.AllowOutOfStockOrders == false && combination.StockQuantity == 0)
{
isAvailable = false;
}
else
{
isAvailable = true;
}
foundCombination = true;
break;
}
}
if (foundCombination == true)
{
break;
}
}
var pvaValueModel = new ProductDetailsModel.ProductVariantAttributeValueModel()
{
Id = pvaValue.Id,
Name = pvaValue.GetLocalized(x => x.Name),
ColorSquaresRgb = pvaValue.ColorSquaresRgb, //used with "Color squares" attribute type
IsPreSelected = pvaValue.IsPreSelected,
isAvailable = isAvailable,
};
@foreach (var pvaValue in attribute.Values)
{
if (pvaValue.isAvailable == true) {
<option selected="@pvaValue.IsPreSelected" value="@pvaValue.Id">@pvaValue.Name
@(!String.IsNullOrEmpty(pvaValue.PriceAdjustment) ? " [" + pvaValue.PriceAdjustment + "]" : null)
</option>
}
else
{
<option selected="@pvaValue.IsPreSelected" value="@pvaValue.Id" style="color: #999999">@pvaValue.Name
[@T("Attribute.Value.SoldOut")]
@(!String.IsNullOrEmpty(pvaValue.PriceAdjustment) ? " [" + pvaValue.PriceAdjustment + "]" : null)
</option>
}
}