VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Daniel Sjöstrand on March 13, 2015, 00:35:39 AM

Title: No "notify me" - out of stock with Child variant
Post by: Daniel Sjöstrand on March 13, 2015, 00:35:39 AM
Dear Virituosos

I have a strange bug

When i have a product that has both children that is in stock and other that are out of stock. It wont replace the add to cart bar to the notify button
You can see it here:
http://urda-new.se.preview.binero.se/component/virtuemart/675/57/tunikor-overplagg/tunika-linneplagg/tunika-i-ofargat-linne-detail?Itemid=0
(the tunika in Size L is out of stock)

When both children is out of stock it works:
http://urda-new.se.preview.binero.se/component/virtuemart/930/45/mantel-cape/klassisk-mantel/mantel-i-vitt-ylle-detail?Itemid=0

And also for single products..

Stock control is working however so customer cannot place products that is out of stock in the cart, but is nagging me that the "notify" button does not appear.

It s also the same on default template

Joomla 3.4
VirtueMart 3.0.6.2

Include here my product template, although i don't think there is anything wrong with this one - but who am I to guess :)
Title: Re: No "notify me" - out of stock with Child variant
Post by: Daniel Sjöstrand on March 18, 2015, 12:19:46 PM
Still havn't figured this one out.... 
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on March 18, 2015, 14:18:49 PM
Yes I noticed the same issue yesterday, I though it was a template issue but nope, seems to be a problem of vm.

I'm using same versions as him.

Please take a look at it, we have currently set the shop to hide products out of stock due to this bug.

Regards
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on March 26, 2015, 11:25:06 AM
This bug is still present in vm 3.0.6.4
Title: Re: No "notify me" - out of stock with Child variant
Post by: Daniel Sjöstrand on April 07, 2015, 12:41:24 PM
Also present in 3.0.7
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on April 21, 2015, 14:22:25 PM
And still present in 3.0.8
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on April 25, 2015, 15:01:53 PM
Open this file:
components/com_virtuemart/views/default_addtocart.php

Look for this line:

if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {

Before this line paste this code:

$db = JFactory::getDbo ();
$q = "SELECT l.product_name,product_in_stock FROM `#__virtuemart_products_" . VmConfig::$vmlang . "` l
JOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id
   WHERE p.virtuemart_product_id = " . $this->product->virtuemart_product_id;
$db->setQuery ($q);
$item = $db->loadObject ();
$this->product->product_in_stock = $item->product_in_stock;


Title: Re: No "notify me" - out of stock with Child variant
Post by: Daniel Sjöstrand on April 27, 2015, 16:14:59 PM
Sorry No change....

Edited components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php

http://www.urda.se/medeltidsklader/medeltida-tunikor-skjortor/tunika-linneplagg/tunika-i-ofargat-linne-detail.html

Tunika i ofärgat linne Strl L -< is out of stock
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on April 27, 2015, 16:31:48 PM
I have had the same strange bug and for me the workaround works.

The problem was the variable $this->product->product_in_stock - it gives back curious values here

Try
echo $this->product->product_in_stock;
above the line and see what the values for your variants are...

Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on April 29, 2015, 11:20:50 AM
Hi thanks for the code, sadly it didnt work for me either.

I still get the "add to cart" in the out of stock childs.

What I wonder also -

In the dropdown of the parent product showing the childs, the out of stock childs are supposed to be shown in a different way? This would help customers really to identify out of stock products easily.

Regards
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on April 29, 2015, 23:38:09 PM
Maybe you have an override of the default_addtocart.php in /templates/<yourTemplate>/html/com_virtuemart/productdetails ?

If not, the part in your default_addtocart.php is really looking like this?

</script>

<?php // Display the quantity box 


/* Load the product details */

//EDIT: Read $this->product->product_in_stock from DB, values are wrong
$db JFactory::getDbo ();
$q "SELECT l.product_name,product_in_stock FROM `#__virtuemart_products_" VmConfig::$vmlang "` l
JOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id
   WHERE p.virtuemart_product_id = " 
$this->product->virtuemart_product_id;
$db->setQuery ($q);
$item $db->loadObject ();

$this->product->product_in_stock $item->product_in_stock;
//



$stockhandle VmConfig::get ('stockhandle''none');
if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock $this->product->product_ordered) < 1) {
?>




If yes, please insert this line above the word EDIT:

echo $this->product->product_in_stock;

If you select a variant in the frontend, It shows you its stock-quantity - are the values right?

Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on April 30, 2015, 12:25:43 PM
Hello

We did have an override but I deleted It and tried again with no result:

<?php // Display the quantity box

$stockhandle VmConfig::get ('stockhandle''none');
echo $this->product->product_in_stock;
//EDIT: Read $this->product->product_in_stock from DB, values are wrong
$db JFactory::getDbo ();
$q "SELECT l.product_name,product_in_stock FROM `#__virtuemart_products_" VmConfig::$vmlang "` l
JOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id
   WHERE p.virtuemart_product_id = " 
$this->product->virtuemart_product_id;
$db->setQuery ($q);
$item $db->loadObject ();
$this->product->product_in_stock $item->product_in_stock;
//


We have a line that doesnt seem to appear in the same order:

$stockhandle = VmConfig::get ('stockhandle', 'none');

Im using vm 3.0.8

Could you please upload the file here? You can rename it to txt.

Regards


Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on April 30, 2015, 18:53:21 PM
3.0.8 here too

File attached. But the order is not important...

I see you have added the echo line - what are the results?

If the shown stock quantitys for all variants are right, this workaround will not help you.
If they are wrong, move the echo line to the bottom of the workaround code. Now they should be right...
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on May 01, 2015, 16:43:56 PM
Thanks for file, Had no effect I still get the notify.
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on May 01, 2015, 18:04:14 PM
again:

I see you have added the echo line - what are the results?

If the shown stock quantitys for all variants are right, this workaround will not help you.
If they are wrong, move the echo line to the bottom of the workaround code. Now they should be right...
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on May 03, 2015, 17:39:59 PM
Quote from: nub on May 01, 2015, 18:04:14 PM
again:

I see you have added the echo line - what are the results?

If the shown stock quantitys for all variants are right, this workaround will not help you.
If they are wrong, move the echo line to the bottom of the workaround code. Now they should be right...

Sorry I have no clue on where to see those results.
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on May 03, 2015, 20:09:02 PM
Quote from: lindapowers on May 03, 2015, 17:39:59 PM
Sorry I have no clue on where to see those results.

They should appear very near to the add to cart button.
If they dont appear check your overrides again please.

Title: Re: No "notify me" - out of stock with Child variant
Post by: GJC Web Design on May 03, 2015, 22:54:17 PM
I think this is the same problem I came across with the child stock getting over written in the product model

as a dirty hack around line 796 in the getProduct() function of administrator/components/com_virtuemart/models/product.php

//GJC  fix for child stock
   $child->child_stock = $child->product_in_stock;
//GJC

then in templates etc the correct stock for the child is available as $this->product->child_stock
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on May 03, 2015, 23:02:32 PM
Ahh, thanks again!

Your dirty hack looks much cooler than my DB request, but i can make it in an override... Hmm 
Title: Re: No "notify me" - out of stock with Child variant
Post by: GJC Web Design on May 03, 2015, 23:05:59 PM
indeed - would need to be replaced every up grade - but pretty sure I told Max about this so maybe fixed in 3.0.10
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on May 04, 2015, 19:28:18 PM
Quote from: GJC Web Design on May 03, 2015, 22:54:17 PM
I think this is the same problem I came across with the child stock getting over written in the product model

as a dirty hack around line 796 in the getProduct() function of administrator/components/com_virtuemart/models/product.php

//GJC  fix for child stock
   $child->child_stock = $child->product_in_stock;

Hi

I tried adding it but dont know if in the correct place since I copied you from http://forum.virtuemart.net/index.php?topic=127500.45:

if (!$child->published && $onlyPublished) {
self::$_products[$productKey] = false;
return FALSE;
}
//GJC  fix for child stock
$child->child_stock = $child->product_in_stock;
//GJC

if(!isset($child->orderable)){
$child->orderable = TRUE;



Quote from: GJC Web Design on May 03, 2015, 22:54:17 PM

then in templates etc the correct stock for the child is available as $this->product->child_stock

I don't understand what you mean here? Is there another file to modify apart from product.php

I added the code but still get the add to cart button :(

Regards



Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on May 04, 2015, 23:42:38 PM
@lindapowers: Try it below this line:
$child = $this->getProductSingle ($virtuemart_product_id, $front,$quantity,true,$virtuemart_shoppergroup_ids);


Btw. The bug has gone for me  :o I have removed my DB request and am not using the GJC fix - but it works, the stock values are ok and the button appears when it should... The only thing i have changed is the default editor (JCE now). Switched back to Tiny MCE - but the bug is still away  :o
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on May 05, 2015, 12:25:09 PM
Quote from: nub on May 04, 2015, 23:42:38 PM
@lindapowers: Try it below this line:
$child = $this->getProductSingle ($virtuemart_product_id, $front,$quantity,true,$virtuemart_shoppergroup_ids);


Btw. The bug has gone for me  :o I have removed my DB request and am not using the GJC fix - but it works, the stock values are ok and the button appears when it should... The only thing i have changed is the default editor (JCE now). Switched back to Tiny MCE - but the bug is still away  :o

lol

Well in my case this is driving me mad, check this product: http://comenaranjas.com/en/shop/seasonal-fruits/yellow-plums-kg-detail.html

Has stock 0 in backend but when I enable "show stock" in template settings is showing the stock of the other child in the dropdown.

And as you can see the "add to cart" is showing also.

Strange
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on May 05, 2015, 12:48:28 PM
And for each product all variants shows the same stock - its definitively  the same problem i have had.
So its strange that my workaround and the GJC fix didn't help you... 

Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on May 05, 2015, 13:05:29 PM
Quote from: nub on May 05, 2015, 12:48:28 PM
And for each product all variants shows the same stock - its definitively  the same problem i have had.
So its strange that my workaround and the GJC fix didn't help you... 



I contacted the template providers (yagendoo). They use their own nasty plugin/framework which caused issues in the past but im sure they will reply this is a vm core issue...

What I would like to know is if the rest of users with setting:

vm/configuration/shopfront/Action when a Product is Out of Stock/Displays 'Notify Me' instead of 'Add To Cart' button

Have this working or have issues like us.

This only happens with child products... but there must be more users out there with this combination...

Regards

Title: Re: No "notify me" - out of stock with Child variant
Post by: GJC Web Design on May 06, 2015, 10:55:51 AM
What my hack did for me was to correct the child product stock level as the $product->product_in_stock and $this->product->product_in_stock in the templates was wrong

From memory it was showing the parent

with the hack you now also have in the the templates

$product->child_stock and $this->product->child_stock  which I could use where needed (add to cart button logic, stock display etc)
Title: Re: No "notify me" - out of stock with Child variant
Post by: nub on May 06, 2015, 15:45:32 PM
Quote from: GJC Web Design on May 06, 2015, 10:55:51 AM
What my hack did for me was to correct the child product stock level as the $product->product_in_stock and $this->product->product_in_stock in the templates was wrong

From memory it was showing the parent

No it shows the selected childs stock.
In the case of lindapowers the template was the problem, it makes a lot of own stuff, other filenames and variables etc.
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on May 06, 2015, 16:53:49 PM
Quote from: nub on May 06, 2015, 15:45:32 PM
Quote from: GJC Web Design on May 06, 2015, 10:55:51 AM
What my hack did for me was to correct the child product stock level as the $product->product_in_stock and $this->product->product_in_stock in the templates was wrong

From memory it was showing the parent

No it shows the selected childs stock.
In the case of lindapowers the template was the problem, it makes a lot of own stuff, other filenames and variables etc.


Yep once more the templater providers driving me crazy ;) thanks for the fix nub!
Title: Re: No "notify me" - out of stock with Child variant
Post by: GJC Web Design on May 06, 2015, 19:11:52 PM
when in doubt use http://www.virtuemarttemplates.eu/   :P

no bloated script kiddie - "Gee Mum - look what this JS can do!"  - just good clean well supported, easy to adapt templates with enthusiastic support

Just my 2 cents
Title: Re: No "notify me" - out of stock with Child variant
Post by: lindapowers on May 06, 2015, 22:49:18 PM
Quote from: GJC Web Design on May 06, 2015, 19:11:52 PM
when in doubt use http://www.virtuemarttemplates.eu/   :P

no bloated script kiddie - "Gee Mum - look what this JS can do!"  - just good clean well supported, easy to adapt templates with enthusiastic support

Just my 2 cents

Thanks for link, good to know.
Title: Re: No "notify me" - out of stock with Child variant
Post by: ifs-net on August 07, 2016, 23:57:55 PM
Hello,

I have a similar problem and need help pls.

I have textile items with sizes like; S(parent item), M(child item), L(child item)

When the parent is out of stock but the children are still existing, at the category view I am having out of stock (notify me) button.

How can I fix that pls ?


What I want is to have notify me or out of stock only ifs all sizes are out of stock.
Title: Re: No "notify me" - out of stock with Child variant
Post by: Milbo on August 08, 2016, 09:34:45 AM
Quote from: GJC Web Design on May 03, 2015, 23:05:59 PM
indeed - would need to be replaced every up grade - but pretty sure I told Max about this so maybe fixed in 3.0.10


foreach ($attribs as $k=> $v) {
if (strpos($k, "\0")===0) continue;
if ('product_in_stock' != $k and 'product_ordered' != $k) {// Do not copy parent stock into child
if (strpos ($k, '_') !== 0 and empty($child->$k)) {
$child->$k = $v;
// vmdebug($child->product_parent_id.' $child->$k',$child->$k);
}
}
}


I think, I fixed it this way, right?
Title: Re: No "notify me" - out of stock with Child variant
Post by: Milbo on August 08, 2016, 09:36:15 AM
Quote from: ifs-net on August 07, 2016, 23:57:55 PM
I have textile items with sizes like; S(parent item), M(child item), L(child item)

When the parent is out of stock but the children are still existing, at the category view I am having out of stock (notify me) button.

We need a screenshot of your stock config, else we cannot help. Try also always the standard template. the virtuemart version, joomla version, a link to the page, and so on.

Please join us here http://forum.virtuemart.net/index.php?topic=135049.0
Title: Re: No "notify me" - out of stock with Child variant
Post by: ifs-net on August 08, 2016, 21:22:24 PM
Hi Milbo,
I can send you my login details if needed.
I have the same problem with standart template too.

Do you want a backend screen shot or front end pls ?