Hello, I am trying to change the message In stock depends on stock qty in the inventory.
What I did so far is to add this code :
<?php $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product); ?> <?php $qty = "$stock->getQty()"; ?>
and then change from
<?php if ($_product->isAvailable()): ?> <p class="availability in-stock"><span>(<?php echo $this->__('In stock') ?>)</span></p>
<?php else: ?>
<p class="availability out-of-stock"><span>(<?php echo $this->__('Out of stock') ?>)</span></p> <?php endif; ?>
to this
<?php if ($_product->isAvailable() && $qty > 0): ?> <p class="availability in-stock"><span>(<?php echo $this->__('In stock') ?>)</span></p> <?php elseif ($_product->isAvailable() && $qty = 0): ?> <p class="availability in-stock"><span>(<?php echo "hello" ?>)</span></p> <?php else: ?> <p class="availability out-of-stock"><span>(<?php echo $this->__('Out of stock') ?>)</span></p> <?php endif; ?>
but is not working.
What I am doing wrong?
Thanks in advance
Hello @geokat
There's a mistake at:
$qty = 0
The correct way is:
$qty == 0
I hope it helps.
Just been reading about the immense amount of uncertainty right now due to rising cases, US elections and global cues - so wanted to ask if it’s a good time to do some profit booking and probably re-enter if and when the market goes down much further? Or is it just a better idea to think long term and hold positions? krogerfeedback survey
The code is correct now but the result is not changing. When I turn the qty to zero it just say Available and not Hello that I type in the second case.