문제

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

도움이 되었습니까?

해결책

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>

다른 팁

<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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top