qrs
qrs

Reputation: 177

Display Yes/No Drop-Down Attribute in Magento Frontend only if Yes is Selected

I'm trying to display a custom yes/no product attribute only if "yes" is selected. Here's my code so far:

<?php $freeship = Mage::getModel('catalog/product')->load($this->getProduct()->getId())->getAttributeText('free_shipping_discount');
if ($freeship == "yes")
echo '<span class="free-ship">FREE SHIPPING</span>'; ?>

It doesn't produce errors but it doesn't display anything either. Any suggestions?

Thanks

Upvotes: 1

Views: 1582

Answers (2)

Freejoy
Freejoy

Reputation: 283

This works for me:

<?php if ($_product->getFreeShippingDiscount()):?>
<span class="free-ship">FREE SHIPPING</span>            
<?php endif;?>

Upvotes: 0

mpaepper
mpaepper

Reputation: 4022

Maybe it is an uppercase Yes? I would try to use var_dump($freeship) to see whether your variable returns what you expect.

Upvotes: 0

Related Questions