Question

 <div class="stock">
    <?php if($_product->isSaleable()): ?>
        <p class="prodstock"><?php echo $this->__('In stock') ?></p>
    <?php else: ?>
        <p class="prodstock"><?php echo $this->__('Out of stock') ?></p>
    <?php endif; ?>
</div>

I have this piece of code right here currently displaying in stock or out of stock on my store. I want to add a 3rd else to display a custom stock status. How can i do that? Can anyone show me?

This would be my third option:

<p><?php $_product->getAttributeText('custom_status');?></p> 

or at least hide the stock status when a custom status exists.

Was it helpful?

Solution

I think you want something like that

<div class="stock">
    <?php if($_product->isSaleable() && !$_product->getCustomStatus()): ?>
        <p class="prodstock"><?php echo $this->__('In stock') ?></p>
    <?php elseif($_product->getCustomStatus()): ?>
        <p><?php echo $_product->getAttributeText('custom_status');?></p> 
    <?php else: ?>
        <p class="prodstock"><?php echo $this->__('Out of stock') ?></p>
    <?php endif; ?>
</div>

OTHER TIPS

<div class="stock">
    <?php if ($_product->getCustomStatus()) : ?>
        <p class="prodstock-custom"><?php echo $_product->getCustomStatus(); ?></p>
    <?php elseif($_product->isSaleable()): ?>
        <p class="prodstock"><?php echo $this->__('In stock') ?></p>
    <?php else: ?>
        <p class="prodstock"><?php echo $this->__('Out of stock') ?></p>
    <?php endif; ?>
</div>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top