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.

4
  • your custom_status is qty number? some more detail about custom_status. Commented Jul 10, 2017 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? Commented Jul 10, 2017 at 15:02
  • No the custom stock status is text. example: "Please call to order" Commented Jul 10, 2017 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. Commented Jul 10, 2017 at 15:04

2 Answers 2

8

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.