0

I would like to know where you can find the indicator/code that says why a product is red/orange/green.

This is the code I found for what is still in stock. However, the stock is automatically tracked via a plug-in. And can not be adjusted in magento itself. Is there a way to indicate that when the stock is 0 it turns red, and the stock is 10 or less orange and 10 or more green?

Here I can change the text of the stock images, but how to change the indicator when it turns green/orange or red.

<div class="levertijd">
          <span class="title"><?php echo $this->__("Availability:")?></span>  
        <?php if($qtyStock > 0 and $_product->isAvailable()){?>
            <img src="<?php echo $this->getSkinUrl('images/green.png')?>" title="<?php echo $this->__('1 or more pieces in stock')?>"/>
         <?php }else if($qtyStock <= 0 and $_product->isAvailable()){?>
              <img src="<?php echo $this->getSkinUrl('images/orange.png')?>" title="<?php echo $this->__('1 in stock, please contact us')?>"/>
          <?php }else if(!$_product->isAvailable()){?>
                 <img src="<?php echo $this->getSkinUrl('images/red.png')?>" title="<?php echo $this->__('0 in stock, please contact us')?>"/>
          <?php } ?>  
     </div>
0

try below code

<?php
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
$qtyStock =$stock->getQty();
?>


<div class="levertijd">
          <span class="title"><?php echo $this->__("Availability:")?></span>  
        <?php if($qtyStock > 10 and $_product->isAvailable()){?>
            <img src="<?php echo $this->getSkinUrl('images/green.png')?>" title="<?php echo $this->__('1 or more pieces in stock')?>"/>
         <?php }else if($qtyStock >= 0 and $_product->isAvailable()){?>
              <img src="<?php echo $this->getSkinUrl('images/orange.png')?>" title="<?php echo $this->__('1 in stock, please contact us')?>"/>
          <?php }else if(!$_product->isAvailable()){?>
                 <img src="<?php echo $this->getSkinUrl('images/red.png')?>" title="<?php echo $this->__('0 in stock, please contact us')?>"/>
          <?php } ?>  
     </div>
| improve this answer | |
0

This was the trick! Due to stock with negative amount we changed it to this:

    <div class="levertijd">
          <span class="title"><?php echo $this->__("Availability:")?></span>  
        <?php if($qtyStock >= 5 and $_product->isAvailable()){?>
            <img src="<?php echo $this->getSkinUrl('images/green.png')?>" title="<?php echo $this->__('5 or more pieces in stock')?>"/>
         <?php }else if($qtyStock > 0 and $qtyStock < 5 and $_product->isAvailable()){?>
              <img src="<?php echo $this->getSkinUrl('images/orange.png')?>" title="<?php echo $this->__('less than 5 in stock')?>"/>
          <?php }else if($qtyStock <= 0 or !$_product->isAvailable()){?>
                 <img src="<?php echo $this->getSkinUrl('images/red.png')?>" title="<?php echo $this->__('0 in stock, please contact us')?>"/>
          <?php } ?>  
     </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.