News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

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

drukman2000

Quote from: maxispin on November 05, 2013, 17:32:38 PM
Quote from: drukman2000 on November 05, 2013, 12:02:54 PM
All,

Attached is the amended stockable.php.
It solve the weight & many other dimensions issues.
Now ALL Stockable Variants are passed into the cart correctly.
As a result now for example you may charge shipment according to weight.

All the best - Drukman.

Thanks Drukman!

Hi maxispin,

It is my pleasure.

Drukman

rhks8

Quote from: maxispin on November 04, 2013, 10:08:33 AM
Quote from: inu2005 on November 04, 2013, 01:32:55 AM
When using the stockable variants plugin I don't understand how I can change the sorting order/rearranging of child products in the dropdownbox.
This is a BIG PROBLEM (bug??) and I read a lot of posts from people who are struggling with this issue since more than a year ago and there has never been given a real solution.

Example:
If I have created earlier child products S/M/L in that order and I want to add XS later it will be visible in the dropdownbox like: S/M/L/XS.
It must be possible to rearrange the order to: XS/S/M/L, but I don's see how I can do this.
I see there is a child product ordering option down the Product Information Tab, but that does not seem to change the order in the dropdownbox.
New created child products also seems to be listed randomly. Who can help???

I use Virtuemart 2.0.24 / Joomla 2.5.14

I have also found this problem: http://forum.virtuemart.net/index.php?topic=119846.msg407982#msg407982.

The ordering is missing a function doing that.  Now it seems that the options are ordered based on the id of child.

Thus, the plugins stockable variant with child products is unusable.

I have had a go at fixing this and have found the following solution:

Open \plugins\vmcustom\stockable\stockable.php

Around line 532 you should see the following query:
$q = 'SELECT CONCAT( `product_name`, " [' .JText::_('COM_VIRTUEMART_PRODUCT_SKU').'"," : ",`product_sku`,"]") as product_name,`virtuemart_product_id` as id, `product_in_stock` as stock FROM `#__virtuemart_products_'.VMLANG.'` as l '
. ' JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)'
. 'WHERE `product_parent_id` ='.(int)$child_id;


On the next line add

$q.= ' ORDER BY `pordering`';

So you should end up with

$q = 'SELECT CONCAT( `product_name`, " [' .JText::_('COM_VIRTUEMART_PRODUCT_SKU').'"," : ",`product_sku`,"]") as product_name,`virtuemart_product_id` as id, `product_in_stock` as stock FROM `#__virtuemart_products_'.VMLANG.'` as l '
. ' JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)'
. 'WHERE `product_parent_id` ='.(int)$child_id;
$q.= ' ORDER BY `pordering`';


Now when editing a product in the VM admin area, under the 'Product Information' tab you can set the ordering of child products.  Save.  This should carry through to the custom fields tab and the dropdown lists shown on the front end.

I hope this helps (it sure gave me a headache).

inu2005

rhks8 YOU ARE GREAT !!! This issue is SOLVED !!! The VM team should be notified about this.

Quote from: rhks8 on November 18, 2013, 09:10:13 AM
Quote from: maxispin on November 04, 2013, 10:08:33 AM
Quote from: inu2005 on November 04, 2013, 01:32:55 AM
When using the stockable variants plugin I don't understand how I can change the sorting order/rearranging of child products in the dropdownbox.
This is a BIG PROBLEM (bug??) and I read a lot of posts from people who are struggling with this issue since more than a year ago and there has never been given a real solution.

Example:
If I have created earlier child products S/M/L in that order and I want to add XS later it will be visible in the dropdownbox like: S/M/L/XS.
It must be possible to rearrange the order to: XS/S/M/L, but I don's see how I can do this.
I see there is a child product ordering option down the Product Information Tab, but that does not seem to change the order in the dropdownbox.
New created child products also seems to be listed randomly. Who can help???

I use Virtuemart 2.0.24 / Joomla 2.5.14

I have also found this problem: http://forum.virtuemart.net/index.php?topic=119846.msg407982#msg407982.

The ordering is missing a function doing that.  Now it seems that the options are ordered based on the id of child.

Thus, the plugins stockable variant with child products is unusable.

I have had a go at fixing this and have found the following solution:

Open \plugins\vmcustom\stockable\stockable.php

Around line 532 you should see the following query:
$q = 'SELECT CONCAT( `product_name`, " [' .JText::_('COM_VIRTUEMART_PRODUCT_SKU').'"," : ",`product_sku`,"]") as product_name,`virtuemart_product_id` as id, `product_in_stock` as stock FROM `#__virtuemart_products_'.VMLANG.'` as l '
. ' JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)'
. 'WHERE `product_parent_id` ='.(int)$child_id;


On the next line add

$q.= ' ORDER BY `pordering`';

So you should end up with

$q = 'SELECT CONCAT( `product_name`, " [' .JText::_('COM_VIRTUEMART_PRODUCT_SKU').'"," : ",`product_sku`,"]") as product_name,`virtuemart_product_id` as id, `product_in_stock` as stock FROM `#__virtuemart_products_'.VMLANG.'` as l '
. ' JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)'
. 'WHERE `product_parent_id` ='.(int)$child_id;
$q.= ' ORDER BY `pordering`';


Now when editing a product in the VM admin area, under the 'Product Information' tab you can set the ordering of child products.  Save.  This should carry through to the custom fields tab and the dropdown lists shown on the front end.

I hope this helps (it sure gave me a headache).

maxispin

VM 3.0.17.6 | VM 2.0.24c | VM 1.1.9

OpenGlobal

Sorry, the forum hasn't been sending me the email notifications about updates to this thread so I've missed all of this. I'll look into this a bit further, run some tests and hopefully get this added to the main virtueMart release.

OpenGlobal E-commerce

maxispin

VM 3.0.17.6 | VM 2.0.24c | VM 1.1.9

OpenGlobal

Quote from: inu2005 on November 20, 2013, 15:06:35 PM
rhks8 YOU ARE GREAT !!! This issue is SOLVED !!! The VM team should be notified about this.

Unfortunately it doesn't. It suffers from the same problem that my previous attempts have suffered from. It doesn't have any effect on the front end, only the backend. The front end variable is still ordered by the product ID.

I realised a while ago that the front end needs to be restructured to fix this problem, hence why I haven't gotten around to it yet.

OpenGlobal E-commerce

OpenGlobal

I have implemented a more comprehensive fix for the child values being brought through to the parent when it is added to the cart (weights and dimensions, etc), which I've put in the attached file.

I'd appreciate it if as many people as possible could test this to make sure that it doesn't introduce any other errors before I commit it to VM.

OpenGlobal E-commerce

[attachment cleanup by admin]

inu2005

QuoteI have implemented a more comprehensive fix for the child values being brought through to the parent when it is added to the cart (weights and dimensions, etc), which I've put in the attached file.

I'd appreciate it if as many people as possible could test this to make sure that it doesn't introduce any other errors before I commit it to VM.

OpenGlobal, I have tested your stockable.php.

My first test  - based on 1 custom field (size S/M/L/XL) - was successful (but also with the solution of rhks8 which I have been testing earlier this week...).  If you reorder and save the childs (TAB article information of the parent) this new order is visible in TAB custom fields. This new order is also used in the dropdownlist. To be effective I had to save again the order of the custom fields TAB of the parent.

My second test – which has 2 custom filelds (colours: WHITE and BLACK and size: S/M/L/XL)  – can be reordered (TAB article information of the parent). This new order is visible in TAB custom fields. However, this new order is not effective for the dropdownlist. I saved it again, cleared cache: the dropdownlist order doesn't change.

My conclusion for the moment is that when your are using your stockable.php and want to reorder the childs to create a logical dropdownlist order (S/M/L/XL and not L/M/S/XL)  this is possible if you have a single custom field. It does not work if you are dealing with more custom fields.

If I can help you with more testing, no problem!

OpenGlobal

Hi,

Thanks very much for your testing. Yes, I found the same thing with the proposed ordering fix. The front end ordering is based on the product ID (a legacy problem that I inherited :-) ) rather than the order that it comes out from the SQL query, so a complete solution for product ordering is still outstanding.

OpenGlobal E-commerce

Milbo

Using correct childs and using the product id is exactly what we want to have.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

OpenGlobal


ArhoN

Quote from: Limonbay on October 30, 2013, 13:03:50 PM
Hi,

I have just upgraded to 2.0.24 and I have this problem with stockable.php:

If you are using stockable variants and have got 5 T-shirts, 2 black and 3 white. If you select 3 black, it will add only 2 (which is ok), but if you Add to Cart again, you get 4 into the cart (which is wrong), It never should be more than 2 and a "Notify me" sign should show up. I have already set this option in VM>Configuration

I have tried this code below but If I use it I get a blank page in 2.0.24

Is it any way to solve this issue? Thanks

QuoteFor those who also want to prevent users from adding more items than you have in stock to their cart (by clicking the Add to Cart button multiple times), change the plgVmOnAddToCart() function in stockable.php (near the end of the file) to the following:
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;

$this->stockhandle = VmConfig::get('stockhandle','none');
if ('disableit' == $this->stockhandle || 'disableit_children' == $this->stockhandle || 'disableadd' == $this->stockhandle) {
if (!class_exists ('VirtueMartCart')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
}
$cart = VirtueMartCart::getCart ();print_r($product);print_r($cart);

$orderedQuantity = $product->quantity;
foreach ($cart->products as $cartProduct) {
if ($cartProduct->virtuemart_product_id == $product->virtuemart_product_id) {
$orderedQuantity += $cartProduct->quantity;
if ($orderedQuantity > $product->product_in_stock) {
return false;
}
}
}
}
}
}

Limonbay is right. If you have a stock for 2 for a particular child item and you add 3 items you get the message that "max quantity is reached. only 2 items are added to your cart" and 2 items are added to the cart but if you close the popup and you add another item of the same child item it is also added to the cart. This happens also if you navigate out of the product description and back again.
In VM1 the system didnt have so many capabilities but it could handle stock items really good. The stock management is very crucial for an e-commerce platform so you must take a good care on this matter.
Keep up the good work

OpenGlobal

What version are you using, that should already be fixed.

OpenGlobal E-commerce

ArhoN