Author Topic: What bugs do you know of in stockable variants plugin  (Read 167619 times)

drukman2000

  • Jr. Member
  • **
  • Posts: 51
Re: What bugs do you know of in stockable variants plugin
« Reply #330 on: November 06, 2013, 07:15:27 am »
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

  • Beginner
  • *
  • Posts: 2
Re: What bugs do you know of in stockable variants plugin
« Reply #331 on: November 18, 2013, 09:10:13 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:
Code: [Select]
$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

Code: [Select]
$q.= ' ORDER BY `pordering`';
So you should end up with

Code: [Select]
$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

  • Beginner
  • *
  • Posts: 19
Re: What bugs do you know of in stockable variants plugin
« Reply #332 on: November 20, 2013, 15:06:35 pm »
rhks8 YOU ARE GREAT !!! This issue is SOLVED !!! The VM team should be notified about this.

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:
Code: [Select]
$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

Code: [Select]
$q.= ' ORDER BY `pordering`';
So you should end up with

Code: [Select]
$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

  • Jr. Member
  • **
  • Posts: 174
Re: What bugs do you know of in stockable variants plugin
« Reply #333 on: November 21, 2013, 11:01:02 am »
I love you rhks8 !

Thank you Very Much!
VM 3.0.17.6 | VM 2.0.24c | VM 1.1.9

OpenGlobal

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 316
    • OpenGlobal E-commerce Web Design in Gloucester
Re: What bugs do you know of in stockable variants plugin
« Reply #334 on: November 21, 2013, 11:03:44 am »
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

  • Jr. Member
  • **
  • Posts: 174
Re: What bugs do you know of in stockable variants plugin
« Reply #335 on: November 21, 2013, 11:09:13 am »
Good to hear OpenGlobal ! Thanks in advance
VM 3.0.17.6 | VM 2.0.24c | VM 1.1.9

OpenGlobal

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 316
    • OpenGlobal E-commerce Web Design in Gloucester
Re: What bugs do you know of in stockable variants plugin
« Reply #336 on: November 24, 2013, 12:18:52 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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 316
    • OpenGlobal E-commerce Web Design in Gloucester
Re: What bugs do you know of in stockable variants plugin
« Reply #337 on: November 24, 2013, 13:08:37 pm »
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

  • Beginner
  • *
  • Posts: 19
Re: What bugs do you know of in stockable variants plugin
« Reply #338 on: November 25, 2013, 21:51:50 pm »
Quote
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, 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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 316
    • OpenGlobal E-commerce Web Design in Gloucester
Re: What bugs do you know of in stockable variants plugin
« Reply #339 on: November 25, 2013, 23:27:42 pm »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10101
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: What bugs do you know of in stockable variants plugin
« Reply #340 on: November 26, 2013, 17:31:10 pm »
Using correct childs and using the product id is exactly what we want to have.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

OpenGlobal

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 316
    • OpenGlobal E-commerce Web Design in Gloucester
Re: What bugs do you know of in stockable variants plugin
« Reply #341 on: November 26, 2013, 17:32:34 pm »
What do you mean?

OpenGlobal E-commerce

ArhoN

  • Beginner
  • *
  • Posts: 10
Re: What bugs do you know of in stockable variants plugin
« Reply #342 on: November 26, 2013, 22:13:53 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

Quote
For 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:
Code: [Select]
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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 316
    • OpenGlobal E-commerce Web Design in Gloucester
Re: What bugs do you know of in stockable variants plugin
« Reply #343 on: November 26, 2013, 22:57:27 pm »
What version are you using, that should already be fixed.

OpenGlobal E-commerce

ArhoN

  • Beginner
  • *
  • Posts: 10
Re: What bugs do you know of in stockable variants plugin
« Reply #344 on: November 27, 2013, 18:38:38 pm »
Im sorry..
Using the Latest VM 2.0.24c