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

farangprod

Quote from: OpenGlobal on October 04, 2013, 12:33:37 PM
I can't replicate your problem. I can't order any 10m2 ones. I can order 4 black 4m2 and 2 white 4m2.

OpenGlobal E-commerce

i have updated vm to 2.0.24 and now, you're right, idon't have this problem anymore... i just can add 10 items in cart even if i have only 2 in stock!

Florentp

Something weird that i never complain about before... The fact that stockable variants plugin add thousands of javascript lines in my categories pages.
For example on this page : beta.indienboutique.fr/fr/homme/t-shirts

Stockable variants plugin add like 4000 javascript lines on the page ! It's huge !
Can it be lighter, or maybe in a separated file ?
Web programmer. Passionate.
PHP, SQL, Javascript, JQuery, css.
Skype : florent.indienboutique

OpenGlobal

Unfortunately no. Because you can order from the category page, every product needs to have it's javascript added to the category page too.

The ability to order from the category page was added fairly recently compared to the stockable functionality. It would be better to rewrite the whole stockable plugin so that the javascript doesn't need to be added for each product individually. But we're intending to rewrite the Generic Cart Variant to combine the functionality instead.

OpenGlobal E-commerce

Florentp

What about add an option to active or unactive the insert of javascript code for website like mine,
which are not using a "add to cart" fuction directly from category page ?
Web programmer. Passionate.
PHP, SQL, Javascript, JQuery, css.
Skype : florent.indienboutique

Limonbay

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;
}
}
}
}
}
}
Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24

OpenGlobal

Here is the latest version that I have, not sure if this is the same as 2.0.24.

OpenGlobal E-commerce

[attachment cleanup by admin]

Limonbay

Thanks OpenGlobal,

I have changed my stockable.php for yours but the product doesn't get added to the cart and I get a pop up saying "Continue shopping - Undefined" and nothing happens.  :P
Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24

OpenGlobal


Limonbay

#308
Here's a link with an example   :)

I have also noticed that after update to 2.0.24 prices don't show up in the product page (as you'll see in the linked page)
Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24

Jörgen

#309
Hello :)

Works good with Firefox 25.0 and with Explorer 8.06, both on Windows XP. But the first product takes a veeeeery long until it drops into the basket on IE 8.
I can add both verde and bianco versions of the skateboards. New lines added for each addition. But the price is hidden though.

regards

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

Limonbay

Thank you Jörgen,

The problem is that now I have a stock of 3 products in green and 5 in blue. If you press "Add to cart" again and again, it will add them regardless of the real available stock.


Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24

Jörgen

Hello Limonbay

I thought Your last reply said "Continue shopping - Undefined", so I didn´t check the stock values.

I can only add 2 of the blue = blanco ???, shouldn´t it say white ???
and 3 of the green = verde at one time, but repeatedly I can add this time after time into the shopping cart.

It looks like the stock control is only executed once per row in the shopping cart, not per SKU.

I have not tested what will happen when I come to checkout, but I believe there will be a negative stock :(

regards


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

Limonbay

QuoteI thought Your last reply said "Continue shopping - Undefined"

That was if I use stockable.php proposed by OpenGlobal. If I use the original 2.0.24 version it has this price not shown and stock control problem.  :)
Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24

OpenGlobal

I'm not seeing the "Continue shopping - Undefined" message on your link and it looks like all of the products have the price missing, not just the stockable plugin ones. Is it a problem iwth your template?

OpenGlobal E-commerce

Limonbay

Hi OpenGlobal,

I have the same problem with joomla default template. Example
Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24