News:

Looking for documentation? Take a look on our wiki

Main Menu

No "notify me" - out of stock with Child variant

Started by Daniel Sjöstrand, March 13, 2015, 00:35:39 AM

Previous topic - Next topic

Daniel Sjöstrand

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 :)

Daniel Sjöstrand


lindapowers

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

lindapowers



lindapowers


nub

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;


J 3.4.1 | VM 3.0.8 | PHP 5.5

Daniel Sjöstrand

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

nub

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...

J 3.4.1 | VM 3.0.8 | PHP 5.5

lindapowers

#9
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

nub

#10
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?

J 3.4.1 | VM 3.0.8 | PHP 5.5

lindapowers

#11
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



nub

#12
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...
J 3.4.1 | VM 3.0.8 | PHP 5.5

lindapowers

Thanks for file, Had no effect I still get the notify.

nub

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...
J 3.4.1 | VM 3.0.8 | PHP 5.5