Diego Fabi

Show Availability

7 posts in this topic

Hi, i need show the availability on the module. Something simple i can do this with the defoult module from virtuemart See the code

 <?php

if ($product->product_in_stock > 0) {
$product_in_stock = "normalstock";
$in_stock_tip = JText::_ ('                ');
}
else {
$product_in_stock = "nostock";
$in_stock_tip = JText::_ ('                ');
}
if ( VmConfig::get ('display_stock', 1)) { ?>

<div class="stock-home">
<span class="vm2-<?php echo $product_in_stock ?>" title="Disponibilidad">
<span><a class="modal" title="Disponibilidad" href="index.php?option=com_content&view=article&id=2&tmpl=component" rel="{handler: 'iframe', size: {x: 650, y: 375}}"><?php echo $in_stock_tip ?></a></p><?php echo $in_stock_tip ?></span>
</span>

</div></div>
<?php } ?>

How can i do the same with your module. The function show the 3 states of virtuemart, full, half and empty i like show more but is fine for me now. This code display the avaiavility image nd make a modal box to a custom article.

Basically what we need is the same that you can see here http://www.pccomponentes.com/ see the little green footer on all products, i need something like this but adapted to Virtuemart possibility. Thanks Regards.

Share this post


Link to post
Share on other sites

Hi.

Please try my solution.

1. open file /mod_bt_productslider/classes/virtuemart.php

2. Add this line

$select[] = '`#__virtuemart_products`.`product_in_stock`';

right below line

$select[] = '`#__virtuemart_products`.`product_special`';

2. Find funciton reloadProducts

3. Right above last line of this function

$products = $tmp;

Add this code

if ( VmConfig::get ('display_stock', 1)) {
foreach($tmp as &$product){
//set product
if($product->product_in_stock > 0){
$product->product_in_stock = "normalstock";
$product->in_stock_tip = JText::_ ('                ');

}else{
$product->product_in_stock = "nostock";
$product->in_stock_tip = JText::_ ('                ');

}
}
}else{
foreach($tmp as &$product){
$product->product_in_stock = false;
}
}

Because we don't call VM config in layout file, so we should call it and assign value to product's properties.

4. Open file layout, example /mod_bt_productslider/tmpl/themes/default/default.php

Use this code to show stock status


<?php if($product->product_in_stock){?>
<div class="stock-home">
<span class="vm2-<?php echo $product->product_in_stock ?>" title="Disponibilidad">
<span><a class="modal" title="Disponibilidad" href="index.php?option=com_content&view=article&id=2&tmpl=component" rel="{handler: 'iframe', size: {x: 650, y: 375}}"><?php echo $product->in_stock_tip ?></a></p><?php echo $product->in_stock_tip ?></span>
</span>

</div>
<?php }?>

I believe that you know where you should put this code to show product stock for all product.

Good luck.

Share this post


Link to post
Share on other sites

Hi, thanks for your respons. I try to do this but nothing happend. I don´t have any error or result.

I have result but was why i put the incomplete code, when i put the full code nothing at all.

Thanks in advance if you can help me.

Share this post


Link to post
Share on other sites

Hi Diego

I'm sorry for my late.

But today, i accessed your server and saw source code.

I see some problems.

1st. In file virtuemart.php you didn't use whole code i gave.

2st. In customized default.php file (in your template) i saw you use a strange variable $disponible and don't use in_stock_tip in my advice (although, it's only a example) . What is $disponible? Maybe you use it in wrong way.

3rd. Can you say your idea again with "Disponibilie" and the right images.

Share this post


Link to post
Share on other sites

I'm sorry, i can't help you with my reply.

But i still believe that this feature can be handled.

I don't only understand why you use the variable without initialize it.

Share this post


Link to post
Share on other sites