I need to display a "sold out" text to all products in a list.phtml file...
I'm using <?php if($_product->isSaleable()) : ?>
and it's working great for simple products but it's not working for configurable.
I've tried few things, and for example this code
if($productType == "configurable") {
$arrayvalori = array("Small"=>"0","Regular"=>"0","Large"=>"0");
$attValConfig = $product->getTypeInstance()->getConfigurableAttributesAsArray();
if(sizeof($attValConfig)) {
$hasAtts++;
foreach($attValConfig as $attValConfigSingle) {
foreach($attValConfigSingle['values'] as $attValConfigSingleVal) {
if($arrayvalori[$attValConfigSingleVal["label"]] > 0) {
echo 'buy';
} else {
echo "sold out";
}
}
}
}
}
it works but returns all of the available attributes statuses (for the given configurable product) output example:
buy
buy
buy
buy
sold out
sold out
buy
I want it to display buy if 1 or more variations are available and display sold out if all are sold out?!?!!
thanks