1

I have this code for the Stock status on the product page, so that if stock is less that 1 is shows as out of stock.

 <?php if ($_product->getStockItem()->getQty() < 1): ?>
            <span class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></span>
        <?php else: ?>
            <span class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></span>
        <?php endif; ?>

I want to add to it so that if stock is < 1 and Manage Stock is yes then, show "out of stock",

So basicly if Manage is no, its always showing in stock.

2
<?php if ($_product->getStockItem()->getQty() < 1 && $_product->getStockItem()->getManageStock()): ?>
    <span class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></span>
<?php else: ?>
    <span class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></span>
<?php endif; ?>
0

It will better idea to use isSaleable() as out of stock checker of product

<?php if (!$_product->isSaleable()): ?>
    <span class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></span>
<?php else: ?>
    <span class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></span>
<?php endif; ?>
3
  • Can you explain "isSaleable" to me? as our current setup we want users to be able to buy goods that are out of stock ( hence the original edit)
    – PaddyD
    Jun 10 '15 at 7:56
  • You can enable Backorders to allow buying products that are out of stock. Go to System > Config > Catalog tab > Inventory > Product Stock Settings > Backorders and allow backorders. No custom code required
    – Jacques
    Jan 31 '17 at 15:18
  • @JaccoAmersfoort that only works if there was 5 in stock and customer order 10. But if stock is 0 then it says "out of stock" and you can't order
    – PaddyD
    Jan 19 '18 at 10:43

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.