Magento 1.9 Attribute Value ‘Yes’ – Available, ‘No’ – Not Available

attributescash-on-deliverymagento-1.9

we created an attribute "Cash on delivery"

using Drop down we gave 2 values "Yes/No"

if the value is "Yes", we are displaying " Available".

if the value is "NO", its not displaying "Not Available". This is the Problem. If Attribute value = "NO", It should display "Not Available" in Frontend.

we are using following code.

<?php 
$attribute = $_product->getResource()->getAttribute('cod_available');
$attribute_value = $attribute ->getFrontend()->getValue($_product);
if ($attribute_value == "Yes")
{?>


<div class="two">?<p class="three"><?php echo "Available";?></p><?php 
 }

else
{?><i class="one"></i>


<p><?php   echo " Not Available";
}
?>
</p>

Best Answer

try this because for yes and no values are saved 0 and 1

 <?php 
    $attribute = $_product->getResource()->getAttribute('cod_available');
    $attribute_value = $attribute ->getFrontend()->getValue($_product);
    if ($attribute_value == 1)
    {?>


    <div class="two">?<p class="three"><?php echo "Available";?></p><?php 
     }

    else
    {?><i class="one"></i>


    <p><?php   echo " Not Available";
    }
    ?>
    </p>