VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: kavoosi127 on May 05, 2014, 02:36:01 AM

Title: show Out of stack in category view
Post by: kavoosi127 on May 05, 2014, 02:36:01 AM
hi
i want to show out of stack in category view..
for example in this page

http://ninimahsool.ir/shop/دسته-بندی-محصولات/وسایل-خواب

under the title of each product if it's out of stack show out of stack!
i know i should edit templates/my_template/html/com_virtuemart/category/default.php but i don't know how!!
please help..
Title: Re: show Out of stack in category view
Post by: GJC Web Design on May 05, 2014, 10:06:21 AM
http://forum.virtuemart.net/index.php?topic=97744.0  I assume you mean Stock  ?
Title: Re: show Out of stack in category view
Post by: kavoosi127 on May 05, 2014, 11:09:48 AM
yes sorry..
i mean stock
i want to add an if sentence like this:
if product stock level<1 then echo 'Out of stock'
can you help me?
Title: Re: show Out of stack in category view
Post by: GJC Web Design on May 05, 2014, 12:31:24 PM
I've pointed you to the relavent page with the way to obtain the stock level...

Title: Re: show Out of stack in category view
Post by: kavoosi127 on May 05, 2014, 13:06:06 PM
<?php
               if ($product->stock->stock_level == '0') {
                  echo 'out of stack' ; }
                  ?>

i added this code but no thing happen!!
i'm poor in php code writing!!
how can i write right code?
Title: Re: show Out of stack in category view
Post by: GJC Web Design on May 05, 2014, 14:28:15 PM
echo out   $product->stock->stock_level to see what it is first .. maybe you need something in config etc

the code snippet is correct if $product->stock->stock_level exists and equals 0

but check what its value is
Title: Re: show Out of stack in category view
Post by: JoomTut on May 06, 2014, 05:18:33 AM
Simple, use this code:
// Availability
if ($product->product_in_stock == 0) { ?>
<div class="availability">
<?php echo "Out of stack"?>
</div>
<?php ?>
   

Advanced, use VirueMart Configuration -> Action when a Product is Out of Stock.