News:

Looking for documentation? Take a look on our wiki

Main Menu

What bugs do you know of in stockable variants plugin

Started by OpenGlobal, May 24, 2012, 14:36:59 PM

Previous topic - Next topic

OpenGlobal

Try adding the code fixes in the latest zip file above.

OpenGlobal E-commerce

klubb

Thank you very much! It works like a charm . One change - one query.

Geppux

#257
Hi OpenGlobal, I just found this thread and I would like to ask you a couple of things. I have this problem using this plugin... I can not assign different discounts to the child product, they always take the discount I set for the parent product. I tried the last zip you posted but without success, I have always the same problem (joomla 2.5.14 - VM 2.0.22a).
I Think this is a bug, together with the fact that changing to different child product you always see the parent images (and not the child image) and that if I select directly a child product I should automatically find in the drop down menus the characteristics of the child I choosed and not the parent one.
Thank you for your answer.
Giuseppe

OpenGlobal

That is beyond the scope of this plugin. The stockable plugin is literally just for creating "stockable variants", if you want to do anything other than stock control with the children, you need to use the Dynamic Child Variants instead.

OpenGlobal E-commerce

Geppux

#259
Thank you for the answer but... I need to create ALSO "stockable variants"... anyway...what is "Dynamic Child Variants"? you told in another post that is just called "Child Variants IIRC" but I didn't found it. Is the same as "Generic Child Variant"?

Giuseppe

OpenGlobal

Hi Giuseppe,

Yes, that's the one.

OpenGlobal E-commerce

Geppux

Thank you OpenGlobal for the answer and for the work you are doing. 
Surely the problems of discounts, images and drop down menu are big lacks for a so nice plugin. I understand that this plugin was created only to have stock control for variants but if the variants can not be considered as a normal product his use is very restricted. I would like to give my help but unfortunately my PHP knowledge is very poor.
Thank you again, bye.
Giuseppe

OpenGlobal

Making changes to the product images, descriptions and other items would be impossible because it would depend entirely on the template being used. I'd like to expand the Generic Child Variant in a future release to give it similar functionality to the Stockable variant plugin.

OpenGlobal E-commerce

fluidfusion

Quote from: Rocked on September 18, 2012, 21:39:43 PM
Here's how to get weight & dimensions for stockable variants passed into the cart! :)

Open plugins/vmcustom/stockable/stockable.php

REPLACE THIS CODE:


public function plgVmOnAddToCart(&$product){
$customPlugin = JRequest::getVar('customPlugin',0);

if ($customPlugin) {
$db = JFactory::getDBO();
$query = 'SELECT  C.* , field.*
FROM `#__virtuemart_customs` AS C
LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
WHERE `virtuemart_product_id` =' . $product->virtuemart_product_id.' and `custom_element`="'.$this->_name.'"';
$query .=' and is_cart_attribute = 1';
$db->setQuery($query);
$productCustomsPrice = $db->loadObject();
if (!$productCustomsPrice) return null;
// if ( !in_array($this->_name,$customPlugin[$productCustomsPrice->virtuemart_custom_id]) ) return false;
$selected = $customPlugin[$productCustomsPrice->virtuemart_customfield_id]['stockable']['child_id'];

if (!$child = $this->plgVmCalculateCustomVariant($product, $productCustomsPrice,$selected) ) return false;
if ($child->product_sku)
$product->product_sku = $child->product_sku;
if ($child->product_name)
$product->product_name = $child->product_name;
$product->product_in_stock = $child->product_in_stock;
}
}


WITH THIS CODE:


public function plgVmOnAddToCart(&$product){
$customPlugin = JRequest::getVar('customPlugin',0);

if ($customPlugin) {
$db = JFactory::getDBO();
$query = 'SELECT  C.* , field.*
FROM `#__virtuemart_customs` AS C
LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
WHERE `virtuemart_product_id` =' . $product->virtuemart_product_id.' and `custom_element`="'.$this->_name.'"';
$query .=' and is_cart_attribute = 1';
$db->setQuery($query);
$productCustomsPrice = $db->loadObject();
if (!$productCustomsPrice) return null;
// if ( !in_array($this->_name,$customPlugin[$productCustomsPrice->virtuemart_custom_id]) ) return false;
$selected = $customPlugin[$productCustomsPrice->virtuemart_customfield_id]['stockable']['child_id'];

if (!$child = $this->plgVmCalculateCustomVariant($product, $productCustomsPrice,$selected) ) return false;

if ($child->product_sku)       $product->product_sku       = $child->product_sku;
if ($child->product_name)    $product->product_name    = $child->product_name;
$product->product_in_stock = $child->product_in_stock;  // Override this even if null.

if ($child->product_weight)    $product->product_weight = $child->product_weight;
if ($child ->product_weight_uom) $product->product_weight_uom = $child->product_weight_uom;
if ($child->product_length) $product->product_length = $child->product_length;
if ($child->product_width) $product->product_width = $child->product_width;
if ($child->product_height) $product->product_height = $child->product_height;
if ($child->product_lwh_uom) $product->product_lwh_uom = $child->product_lwh_uom;
// if ($child->min_order_level) $product->min_order_level = $child->min_order_level;
// if ($child->max_order_level) $product->max_order_level = $child->max_order_level;
}
}



THEN REPLACE THIS CODE:


function getValideChild($child_id ) {
$db = JFactory::getDBO();
$q = 'SELECT `product_sku`,`product_name`,`product_in_stock`,`product_ordered`,`product_availability` FROM `#__virtuemart_products` JOIN `#__virtuemart_products_'.VMLANG.'` as l using (`virtuemart_product_id`) WHERE `published`=1 and `virtuemart_product_id` ='.(int)$child_id ;
$db->setQuery($q);
$child = $db->loadObject();
if ($child) {
if ('disableit_children' === $this->stockhandle) {
$stock = $child->product_in_stock - $child->product_ordered ;
if ($stock>0)return $child ;
else return false ;
}
else return $child ;
}
return false ;
}


WITH THIS CODE:


function getValideChild($child_id ) {
$db = JFactory::getDBO();
$q = 'SELECT `product_sku`,`product_name`,`product_in_stock`,`product_ordered`,`product_availability`,`product_weight`,`product_weight_uom`,`product_length`,`product_width`,`product_height`,`product_lwh_uom` FROM `#__virtuemart_prfoducts` JOIN `#__virtuemart_products_'.VMLANG.'` as l using (`virtuemart_product_id`) WHERE `published`=1 and `virtuemart_product_id` ='.(int)$child_id ;
$db->setQuery($q);
$child = $db->loadObject();
if ($child) {
if ('disableit_children' === $this->stockhandle) {
$stock = $child->product_in_stock - $child->product_ordered ;
if ($stock>0)return $child ;
else return false ;
}
else return $child ;
}
return false ;
}



Notice I commented out a few lines in the first edited function, but you could uncomment them and add those columns (and any others) to the db query in the second function to pull more values from the child to the product added to the cart.

I suggest this be added to the core.  However, it might be best if there were additional parameter options for the custom stockable variants plugin on the backend that lets you choose which values you would like the child to override for the parent.

After you make those changes your weight / dimension based shipping rules should work correctly for any new products added to the cart.

The modified default stockable.php is attached.  Hope this helps someone!  Took me a little while to figure it out.    :)

:D

Have been through all 18 pages of this very useful thread (highest regards to the OP for taking so much time on this) and was thanked for my efforts at page 14 where the shipping weights problem I am having popped up. Unfortunately this fix is not working for the version of VM (2.0.20b) that I am using.

I am selling products with Weight variants, 1kg, 5kg, 15kg and each weight costs a different amount to ship. Of course without change, the cart only calculates the shipping weight of the parent item which is useless.

When I applied the fix about I lost my dropdown box all together so I'm guessing it need re-approaching for the newer versions of VM.

Quite surprised this has not been implemented yet. Any ideas anyone?

OpenGlobal

Have you applied the latest fixes in the zip file on the previous page? I thought I'd fixed this.

OpenGlobal E-commerce

fluidfusion

Hmm, can't seem to see that, probably going blurry having spent the last few hours reading off the screen. I did manage to find this other post: https://forum.virtuemart.net/index.php?topic=115921.0

But still not working for me. Could you point me to the post your are referring to?


Jörgen

#267
Hello Openglobal and thanks for Your efforts.  :)

Sorry but the stockable.php from post #250 doesn´t seem to work.
You could also be interested in this thread. Rainman has tried the stockable.php from the svn and still gets flickering. I have also discovered that the transition between the different options don´t go very well. Custom field data doesn´t seem to be correctly updated, when changing between option. For example when going from Full Lace to Lace Front :(
http://forum.virtuemart.net/index.php?topic=117783.msg398988#msg398988

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

fluidfusion

Quote from: OpenGlobal on August 13, 2013, 09:55:12 AM
https://forum.virtuemart.net/index.php?topic=103067.msg396489#msg396489

OpenGlobal E-commerce

Many thanks, not working but I'm still on v20b. Do you think it might work if I upgrade? I would just upgrade and see but last time I tried the site broke and I had to revert back to a backup.

fluidfusion

Answered my own question here, did a backup version of the site and managed to successfully update to v22a. Still not adding weight info to the cart for child products though.

Any ideas?