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

Problem checking child product qty in adding to cart

Started by paranella, September 08, 2014, 01:12:42 AM

Previous topic - Next topic

paranella

I'm using VM 2.6.10
When I add to cart some quantity for a child product VM check for parent stock quantity not for the child

Real example:
I am in (parent) product detail page (parent id product is 1038)
I choose one child product and add some quantity for the cart (chosen child product id is 1980)

In firebug these parameters are sent:
url: .../index.php?option=com_virtuemart&nosef=1&view=cart&task=viewJS&format=json&lang=it&_=1410127200612

post parameters:
Itemid=773
_=1410127545355
customPlugin[3345][stockable][child_id]=1980
customPlugin[3345][stockable][selectoptions1]=M
customPrice[1][44]=3345
format=json
lang=it
nosef=1
option=com_virtuemart
quantity=1
quantity[]=2
task=addJS
view=cart
virtuemart_product_id[]=1038

you can see that "virtuemart_product_id" param is the parent id product

in file /components/com_virtuemart/helper/cart.php on line 731 is declared "checkForQuantities($product, &$quantity=0,&$errorMsg ='')" function
$product param dump is:
stdClass Object
(
   ...
    [virtuemart_product_id] => 1038 (????? parent product id not child!)
    [product_parent_id] => 1038 (OK)
    [product_sku] => 10213EM (CHILD SKU, OK)
    [product_name] => TAGLIA M (CHILD NAME, OK)
    [product_in_stock] => 10 (CHILD STOCK, OK)
    ...
)

the strange here is that "[virtuemart_product_id]" property is the parent product id instead of the child

then on line 746-748 in the same file there is:
// update the stock info from the database
$product_model = VmModel::getModel('product');
$product = $product_model->getProduct($product->virtuemart_product_id);

so before I had the right child stock, now VM get the wrong parent stock because $product->virtuemart_product_id is the parent id

I Have been clear enough?

nvanzutphen

I think I'm facing exactly the same problem:

A parent product with a stock of 4 (total of the childen) has 2 children, both have a stock of 2. When I order 6 instances of one of the child products, VM reduces the number of products in the cart to 4, which equals the amount of the parents stock instead of the childs stock of 2.
To me it seems the cart simply checks the wrong product, the parent instead of the child, is there a way to fix this? I presume adjusting a bit of code would do the trick?

I'm running an old version of VM 2.0 RC3, unfortunately updating is not an option, the install has already been 'hacked' so I'm completely fine with adjusting any code. I hope you can give me a hint, it means the world to me :-).

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation