VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: bogusj on November 12, 2013, 14:32:03 PM

Title: Is there any way to disallow selling parent products?
Post by: bogusj on November 12, 2013, 14:32:03 PM
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.
Title: Re: Is there any way to disallow selling parent products?
Post by: Maxim Pishnyak on November 12, 2013, 18:03:00 PM
http://forum.virtuemart.net/index.php?topic=79799
Title: Re: Is there any way to disallow selling parent products?
Post by: bogusj on November 13, 2013, 10:16:50 AM
Joomla! 2.5.14
VM 2.0.24
Title: Re: Is there any way to disallow selling parent products?
Post by: Maxim Pishnyak on November 13, 2013, 18:35:00 PM
Did you see http://forum.virtuemart.net/index.php?topic=92756.0 ?
Title: Re: Is there any way to disallow selling parent products?
Post by: bogusj on November 15, 2013, 01:01:18 AM
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?
Title: Re: Is there any way to disallow selling parent products?
Post by: bogusj on November 18, 2013, 10:56:27 AM
Any help here, please?
Title: Re: Is there any way to disallow selling parent products?
Post by: bogusj on November 18, 2013, 13:37:59 PM
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 -->