News:

Looking for documentation? Take a look on our wiki

Main Menu

Is there any way to disallow selling parent products?

Started by bogusj, November 12, 2013, 14:32:03 PM

Previous topic - Next topic

bogusj

Hi,

Is there any way to disallow selling parent products, expect config's option "Do not Display Product, if child products also out of stock"?
It works this way, but my problem is that it shows the product that is out of stock, while this is not the case, since its children products are in stock.
If not, is there a way to show that the parent product is in stock, if any of its children is in stock?

Thanks in advance.




bogusj

I don't get it. The thread talks about availability, but not about the product's children availability.
My problem is that I want the product to show that IS IN STOCK, even if it has ZERO quantity when one of its children products is in stock.
Any code to do this?


bogusj

#6
After experimenting, I came up with the following code that works fine:
File:com_virtuemart/category/default.php
Line: 266
I changed code:

<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>


To (I preserved the old code in comments, just in case):

<!--
<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>
-->
<!-- Start modification for showing normal stock  for products that have children -->
<?php 
$db JFactory::getDBO();
        $db->setQuery(' SELECT COUNT( * ) FROM `#__virtuemart_products` WHERE `product_parent_id` ='.$product->virtuemart_product_id);
$result $db->loadResult();
if ($result == 0) { ?>

<span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"></span>
<?php } else { ?>
<span class="vmicon vm2-<?php echo 'normalstock' ?>" title="<?php echo JText::('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_NORMAL_TIP'?>"></span>
<?php ?>
<span class="stock-level"><?php echo JText::('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'?></span>
<!-- End modification for showing normal stock  for products that have children -->