Author Topic: Product multi variant stock problem  (Read 1204 times)

roman5527

  • Jr. Member
  • **
  • Posts: 155
Product multi variant stock problem
« on: September 26, 2018, 19:10:48 pm »
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4067
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Product multi variant stock problem
« Reply #1 on: September 26, 2018, 22:46:07 pm »
I can change the behavior in my plugin "Professional product Child variants".
See https://shop.st42.fr/en/products/product-child-variants.htm

roman5527

  • Jr. Member
  • **
  • Posts: 155
Re: Product multi variant stock problem
« Reply #2 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.

StefanSTS

  • Global Moderator
  • Full Member
  • *
  • Posts: 520
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Product multi variant stock problem
« Reply #3 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
--
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4067
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Product multi variant stock problem
« Reply #4 on: September 28, 2018, 14:02:46 pm »
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

  • Jr. Member
  • **
  • Posts: 155
Re: Product multi variant stock problem
« Reply #5 on: September 29, 2018, 21:55:27 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

  • Global Moderator
  • Full Member
  • *
  • Posts: 520
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Product multi variant stock problem
« Reply #6 on: September 30, 2018, 16:45:16 pm »
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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9222
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Product multi variant stock problem
« Reply #7 on: September 30, 2018, 18:23:38 pm »
I do this in addtocart.php

Code: [Select]
//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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation