0
 <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.

  • your custom_status is qty number? some more detail about custom_status. – Rama Chandran M Jul 10 '17 at 15:01
  • in what case do you want to display a custom status? Of it's set, or if the product is not salable? – Marius Jul 10 '17 at 15:02
  • No the custom stock status is text. example: "Please call to order" – DevAnd Jul 10 '17 at 15:03
  • Well I would like to display it when I select the custom status from the drop down. I added an attribute so if the attribute is selected then only the custom status should show. – DevAnd Jul 10 '17 at 15:04
6

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>
| improve this answer | |
6
<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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.