News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Product multi variant stock problem

Started by roman5527, September 26, 2018, 19:10:48 PM

Previous topic - Next topic

roman5527

Hello !!!

I have a VM shop with the option "If stock=0 - Show notify button". The client need it in this way.
Then... I have products that I have stock of child's, but I don't have stock of parent !!

In this situation, product is display on site but i see notify button , but the child's have stock.

I need a solution to show notify button on parent product only when all child product stock = 0
Please, someone knows the solution?

Thank's in advance

Best regards :)

Studio 42

I can change the behavior in my plugin "Professional product Child variants".
See https://shop.st42.fr/en/products/product-child-variants.htm

roman5527

Thanks but i need it no only module but in category page and product detail page too.

StefanSTS

Hi Roman,

normally I set the parent that is not orderable to a positve number of available products like 1000000. It will then show "Choose Variant".
If all child products are out of stock, each shows the "Notify me".
In this case the customer sends the notify only from the child, that he actually wants.

Like T-Shirt, color blue, size L.

Only you don't get the notify on the parent if all children are at 0. But the customer would normally want to know when the specific child is available.

Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

Studio 42

Quote from: roman5527 on September 28, 2018, 10:50:11 AM
Thanks but i need it no only module but in category page and product detail page too.
The plugin handle it for all cases same way. In a module, category or product detail

roman5527

#5
Quote from: StefanSTS on September 28, 2018, 12:10:19 PM
Hi Roman,

normally I set the parent that is not orderable to a positve number of available products like 1000000. It will then show "Choose Variant".
If all child products are out of stock, each shows the "Notify me".
In this case the customer sends the notify only from the child, that he actually wants.

Like T-Shirt, color blue, size L.

Only you don't get the notify on the parent if all children are at 0. But the customer would normally want to know when the specific child is available.

Stefan

Hi, StefanSTS. Where i set parent product how is not orderable ? because i used multi variant custom field.
and from this tutorial : https://docs.virtuemart.net/tutorials/product-creation/221-multivariant.html i have parent do not orderable, because i see choose variant in select box.

and this solution is not good.
Because i need when is at least one child product stock > 0 , parent product show choose variant , but when all child product stock = 0 , parent produt show notify me . But when i set stock parent product i never see notify me on parent product.

any idea ? thanks

StefanSTS

Hi Roman,

if you really need to change to "Notify" on the parent product, I don't think there is a core solution to it. As I said, I use that type only with "Choose" for the parent and "Notify" in any or all child products that have a stock of 0.

You would either
1. need a plugin that calculates the available products for the parent from the child products or
2. an override for the productdetails layout that counts the child products if the current product is a parent and accordingly displays "notify" or "Choose".

If you cannot code that yourself, you might ask Max from iStraxx if he can make that layout for you, or if he would consider putting that into core for a supporter membership.

I guess it's not too hard to find the stock level of child products in a parent, but I haven't looked into that yet.
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

GJC Web Design

I do this in addtocart.php

//GJC added to get stock info for childs
$is_in_stock ='0';
$nochildren = 0;
$prodmodel = VmModel::getModel ('product');
$children = $prodmodel->getProductChilds($product->virtuemart_product_id);
if(!empty($children)){
foreach($children as $child) {
if($child->published == 0) {
continue;
}elseif($child->product_in_stock - $child->product_ordered < 1){
continue;
}else{
$is_in_stock++;
}
}
}else{
$nochildren = 1;
}


then switch the label/display of the parent depending on $is_in_stock etc
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Roderic

Quote from: GJC Web Design on September 30, 2018, 18:23:38 PM
I do this in addtocart.php

//GJC added to get stock info for childs
$is_in_stock ='0';
$nochildren = 0;
$prodmodel = VmModel::getModel ('product');
$children = $prodmodel->getProductChilds($product->virtuemart_product_id);
if(!empty($children)){
foreach($children as $child) {
if($child->published == 0) {
continue;
}elseif($child->product_in_stock - $child->product_ordered < 1){
continue;
}else{
$is_in_stock++;
}
}
}else{
$nochildren = 1;
}


then switch the label/display of the parent depending on $is_in_stock etc

I'm trying to implement this piece of code, but not sure where to put it.


I've put in this code into productdetails/default.php:


<?php if (($this->product->product_in_stock $this->product->product_ordered) < 1) { ?>

<p class="instock"><strong><i class="icon-cancel"></i><?php echo vmText::_('COM_VIRTUEMART_CART_PRODUCT_OUT_OF_STOCK'?></strong></p>

<?php
}else{
 
echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product));
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product)); }


This works well for products without childs, not so much for products with childs and parent product not orderable / quantity of 0.

Now my question is, how can I combine the quoted snippet with mine.