News:

Support the VirtueMart project and become a member

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

sucuisine

During checkout the shipment cost have to be  calculated based on the weight of the product. I have several variants of the same products each with an other weight. So I have to define the several child products with several weights

Within vm there are 2 solutions for this using custom fields:
Use a custom field type generic cart variants or use the custom field type plugin.

Using generic cart variant
The child products are being shown in the dropdown box on the detail product page. When a variant is chosen the product is being retrieved, this take approx 5 sec ( too long), and the name of the parent is changed
The calculating of the shipment cost is correct in the cart

There is a workaround (not nice) for the parent name: use the same name for the childs as the parent but use a different sku name. But there is no workaround for the delay in retrieving the product.


Using plugin stockable variants
The child products are being shown in the dropdown box. Changing to the other product variant is easy and fast. But the shipment calculation is based on the weight of the parent even the child is placed in the cart.

Is there a way to configure this that the weight of the child will be used in stead of the weigth of the parent?
Is there an other solution for ship cost based on weight?

Who can help??

OpenGlobal


reggiesingh

Quote from: sucuisine on September 16, 2012, 23:21:13 PM
During checkout the shipment cost have to be  calculated based on the weight of the product. I have several variants of the same products each with an other weight. So I have to define the several child products with several weights

Within vm there are 2 solutions for this using custom fields:
Use a custom field type generic cart variants or use the custom field type plugin.

Using generic cart variant
The child products are being shown in the dropdown box on the detail product page. When a variant is chosen the product is being retrieved, this take approx 5 sec ( too long), and the name of the parent is changed
The calculating of the shipment cost is correct in the cart

There is a workaround (not nice) for the parent name: use the same name for the childs as the parent but use a different sku name. But there is no workaround for the delay in retrieving the product.


Using plugin stockable variants
The child products are being shown in the dropdown box. Changing to the other product variant is easy and fast. But the shipment calculation is based on the weight of the parent even the child is placed in the cart.

Is there a way to configure this that the weight of the child will be used in stead of the weigth of the parent?
Is there an other solution for ship cost based on weight?

Who can help??

Having the same problem here. It's pretty frustrating as the 'generic child variant'  behaves unexpectedly from time to time e.g. sometimes all child options disappear when a certain child product is selected....plus the entire page changes when a child product is selected.

The 'child variant plugin' seems to be the cleanest way to go if you want the parent displayed at all times. If only it can be modified to recognize the weight values of the selected child product instead of the parent.

Disabling shipping by weight until this can be resolved

Site: www.richardhume.com

sucuisine

Hi reggiesingh

Generic child variant is OK except that  the  child product is being retrieved when selecting a variant. This take some seconds and the parents name is then changed.
Calculation of the shipment cost is also OK

But at plugin selection of a variants is Ok ( no product retrievement) but the shipment collection is not ok.

See the test products on www.sucuisine.com bami nasi category

Developer Sucuisine

Rocked

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

[attachment cleanup by admin]
ROCKED LLC - Business Class Web Solutions
RockedStudios.com RockedMarketing.com RockedHosting.com  (Coming Soon) 

Customized VM Setup, Development, Hosting & Design

OpenGlobal

Quote from: Rocked on September 18, 2012, 21:39:43 PM

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;

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


It would be better to wrap the second block of lines in the same style if statements as the first block.

OpenGlobal

Rocked

#201
If you wrap it with if(xxx) before setting the override - you are just saying if it's null do not override that field.  I debated it and decided I wanted it to override it even it was null for weight / dimensions -- maybe it shouldn't though.  Hmm... maybe it would be better to not override it if it null... either way it will work.

I went ahead and modified that code in the post above and added the null checks though.


Here's the way I think this should be implemented into the backend.  See the attached picture. I added a few ideas to this as well -- Threw this together quick... but it gets the idea across pretty well.

[attachment cleanup by admin]
ROCKED LLC - Business Class Web Solutions
RockedStudios.com RockedMarketing.com RockedHosting.com  (Coming Soon) 

Customized VM Setup, Development, Hosting & Design

sucuisine

#202
Many thanks for Rocked and Openglobal

We are going to try this code and will post the results

Regards

Ps the second  part of the code of Rocked has a typo, the table name ' virtuemart_prfoducts' should be ' virtuemart_products'

I am still testing

sucuisine

#203
Hi
I have created a custom field of type plugin
I selected the plugin VM Custom stockable variants and I tried to create the option name with values. It is not possible to same the option save with values.

When selecting the plugin ' Vm custom field with stock control'  then the option name and values are saved.
So I continued with plugin ' Vm custom field with stock control'
In the parent product tab 'custom field' i selected the above created plugin en I created the childproducts and Link to each other.
Issue: the custom field namedisplays on the detail product page but the variants is not being displayed  (no dropdown list).

This issue is resolved. There was a type in the code of Rocked: Prfoduct should be product

I have also tried by creating the child's in the tab product information ' add child product' - > the same issue as above.

Before I was able to see the dropdown list and could place the child in the cart.  In this case I was also not able to save under ' stockable variants'

I am using vm 2.0.10

Who can help? Is the stockable.php of the last vm version 2.0.10?
Or has this to something to do with that the Vm custom stockable variants not being saved?


bodywarmer

Hi I am not sure if this bug has been resolved.

I have updated to the latest version of virtuemart, however I seem to be having the problems with the parent and child variants.
I can order more than are in stock of the child variant by using both the product page and then the final cart.

Also when ordering the child product from the parent, on the pop up window it comes up with that the parent has been added, however when looking at the shopping cart is the correct product.
http://farlixx.co.uk/latest/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=225&virtuemart_category_id=0
Do I need a patch for this?

Help would be much appreciated for this.

sucuisine

#206
I have implement custom field plugin with stock control

Question 1
It is not posible to order 3 different variants of the same product. The second variant is always being replaced in the cart
Answer: issue does not occurs anymore


Question 2
How can I manage the sequence of the child products that is being displayed. I have to create a new variance that should be displayed at the top of the list?

Answer: workaround- change the description of the child records or the sequence of the variants in the in the parent product equal to the sequence in which it appear in the website.


Please who can help me?

Florentp

Guys, please use the last file posted by OpenGlobal. The one in the last release of Virtuemart is too old :)
Web programmer. Passionate.
PHP, SQL, Javascript, JQuery, css.
Skype : florent.indienboutique

OpenGlobal

Quote from: bodywarmer on September 19, 2012, 21:54:15 PM
I have updated to the latest version of virtuemart, however I seem to be having the problems with the parent and child variants.
I can order more than are in stock of the child variant by using both the product page and then the final cart.

This is a known problem with plugins and is unlikely to be fixed any time soon, if at all. Basically, when using custom field plugins, each click on Add to Cart creates a brand new entry in the cart which is not verified against other entries in the cart.


Quote from: bodywarmer on September 19, 2012, 21:54:15 PM
Also when ordering the child product from the parent, on the pop up window it comes up with that the parent has been added, however when looking at the shopping cart is the correct product.

I'll look into this.

OpenGlobal

WillP

Quote from: OpenGlobal on June 04, 2012, 19:09:16 PM
Looking at administrator/..../helpers/cart.php, that last one is going to require a significant change in the way the cart works. It seems that all custom plugins will generate duplicates when added to the cart multiple times. The plugin itself has no way of controlling this and merging them into single lines.

I'll try to raise this with some other devs who may be able to look into it.

OpenGlobal

Hi OpenGlobal,

Is this the problems in example I buy Product A with size S, I click add to cart. Then I repeat it, it generate another Product A with size S instead update previous quantity to 2?
If yes, have you find the solution?

Thanks!