VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: mark R on September 18, 2015, 16:24:14 PM

Title: Multi Variants and Parent Stock QTY.
Post by: mark R on September 18, 2015, 16:24:14 PM
Hi All,

I am having an issues with Multi variants and stock quantities in 3.0.10.

How should i set this up??  If I enter 0 quantity on the Parent product it only displays the Notify Me Option even when I have stock of the child products.

If I put a quantity into the parent it is fine (although this then displays incorrect stock QTY on parent), does the parent quantity get updated when someone buys a child product?

Also I am looking to update the child stock quantities via a PHP script on a regular basis which will not update the parent stock quantity.

I think the easiest solution would be to not display "In Stock" on the product page if it is a parent product, once a buyer selects a size, then display quantity available of that size.

I hope this makes sense.

Any ideas / suggestions would be greatly appreciated.

Many thanks
Mark
Title: Re: Multi Variants and Parent Stock QTY.
Post by: Studio 42 on September 19, 2015, 13:55:47 PM
Hi,
I have the inverted problem, i need to use parent stock for variant(and don't check for child stock).
The product are prints and limited edition. The total autorized edition(stock) is this from parent.
I have other work todo before, but if someone have already a code to verify and change parent stock, this help me.
Thanks,
Patrick
Title: Re: Multi Variants and Parent Stock QTY.
Post by: mark R on September 20, 2015, 17:13:39 PM
H All,

Could someone please point me in the right to hide stock quantities for parent products.

I m thinking of hiding the "In Stock" for all products with an SKU ending in "-" (all my parent sku's end in -)

I am editing the Product Details template and trying something along the lines of :-

<?php if($show_stock) : ?>
  <div class="product-stock-cont col-sm-6">
<?php if substr($this->product->product_sku,-1) = '-'?> // this is what im trying to get working
   <?php $stock VPFrameworkVM::getStockText($this->product); ?>
<span class="<?php echo $stock->class ?> hasTooltip" title="<?php echo $stock->tip ?>"><?php echo $stock->text ?> : <?php echo $this->product->product_in_stock ?></span>
</div>
<?php endif; ?>
<?php endif; ?>


Any help would be much appreciated

Many thanks
Mark

Title: Re: Multi Variants and Parent Stock QTY.
Post by: GJC Web Design on September 20, 2015, 19:59:02 PM
<?php if substr($this->product->product_sku,-1) != '-'; ?>

??
Title: Re: Multi Variants and Parent Stock QTY.
Post by: Studio 42 on September 21, 2015, 00:56:36 AM
<?php if (substr($this->product->product_sku,-1) !== '-' ): ?>
Bracket are missing too. But in all case this is a poor code.
Title: Re: Multi Variants and Parent Stock QTY.
Post by: mark R on September 21, 2015, 07:50:02 AM
Hi,

I am not a programmer so I would expect it to be poor lol. 
It was just to show what I was trying to do.. to hide the stock quantities of parent products on detail pages.

So any help pointing me in the right direction would be much appreciated.

Thanks again
Mark

Sent from my SM-G901F using Tapatalk
Title: Re: Multi Variants and Parent Stock QTY.
Post by: mark R on September 21, 2015, 09:37:16 AM
Many Thanks Studio 42.

Your code does exactly what is was looking for, may I ask why this is the wrong way to do it?

Looks like i'll be booking myself a PHP course.

Thanks again
Mark
Title: Re: Multi Variants and Parent Stock QTY.
Post by: Studio 42 on September 21, 2015, 13:45:16 PM
Only my opinion because you need :
Quote(all my parent sku's end in -)
and can give problem when you have to use another sku
I think it's better to check for product parent_id ==0.
Title: Re: Multi Variants and Parent Stock QTY.
Post by: mark R on September 22, 2015, 08:58:52 AM
Many thanks Studio 42,

Using the "product.parent_id ==0" would have an effect on products that do not have child products.

Thanks again
Mark