Question

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>
Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top