VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: cod3gen on December 14, 2012, 19:16:22 PM

Title: Show stock image in product list depending on stock
Post by: cod3gen on December 14, 2012, 19:16:22 PM
Hello!

Im trying to add a couple futures to the product list to show stock avaibility.
Like when over 5 products in stock, green image, when  under 5 products in stock orange image, and 0 stock red image and extra text. Also count together.

Ive tried this but it will just show green image no mather how many products in stock, is it an easy way to do this?
                        <?php if (($this->product->product_in_stock ) < 5) { ?>
                        <div class="produktlager"><?php echo 'Tilgjengelighet: '$product->product_in_stock'<img src="http://www.mydomain.no/templates/explore/images/Stocked.gif" />' ?></div>


Any one could help?
Title: Re: Show stock image in product list depending on stock
Post by: xcover on December 15, 2012, 11:57:58 AM
Hi,
maybe you can use this:

<div<span class="stock-level"><?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'?></span>

<?php 
$stato "";
$statotip "";
if ($this->product->product_in_stock 1) {
$stato "nostock";
$statotip "Entschuldigung, wir haben derzeit keine Exemplare dieses Artikels auf Lager";

} else {
if ($this->product->product_in_stock 3) {
$stato "lowstock";
$statotip "Sofort Lieferbar, aber nur noch wenige Exemplare auf Lager!";

} else {
$stato "normalstock";
$statotip "Sofort Lieferbar!";
}
?>

<span class="vmicon vm2-<?php echo $stato ?>" title="<?php echo $statotip ?>"></div>
<div class="lagerstatus">
<?php 

if ($this->product->product_in_stock 1) {
echo  "Nicht auf Lager!";
} else {
if ($this->product->product_in_stock 3) {
echo "Wenige Exemplare auf Lager!";
} else {
echo "Auf Lager!";
}
?>

</div>


Greetings
Xcover
Title: Re: Show stock image in product list depending on stock
Post by: lostmail on May 01, 2013, 21:42:20 PM
...works great this code.

But how can i change it in category ?

When i open a category - all products are "green"  - but when i click a product - it`s yellow or red status...

How can i modify the category/views/default.php to work same way like productdisplay ?

QuoteFound this line in category:
               <?php
                  if ( VmConfig::get ('display_stock', 1)) { ?>
                  <!--                   if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none')){?> -->
                  <div class="paddingtop8">
                     <span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"></span>
                     <span class="stock-level"><?php echo JText::_ ('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP') ?></span>
                  </div>
                  <?php } ?>

Title: Re: Show stock image in product list depending on stock
Post by: lostmail on May 01, 2013, 22:10:52 PM
At last:
I´d like to know how the default stock images are working.

I see that there are 3 Status Levels (green, yellow and red) - how does virtuemart set these levels and where can i set at which level the status is yellow/green in backend ????

Should it not be a  standard feature to define at which stock level (count) the image hast to change from one to the other ?