VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: el_carl0s on August 09, 2012, 01:12:22 AM

Title: how does the add to cart button works?
Post by: el_carl0s on August 09, 2012, 01:12:22 AM
hello, im using virtuemart 2.0.8 and joomla 2.5.4

i would like to know how the "add to cart" button works, is there any place where i can get this information?

the thing i would like to know is how the product information is passed to the cart with this button, for example where is the line of code needed for the product name to be added to the cart, or how does the quantity goes from the quantity box to the cart, and which is the .php file those lines are located at?

please i really need this information because i need to be able to add an array of the same product at once

for example: product "X" has a custom field called color  and another custom field called size

i would like to be able to add 1 color "white" size "S" and 2 color "blue" size "M" of the same product with just 1 add to cart click

i already got the custom fields displayed twice and the quantity box too, i only need to know how to add this to the cart as an array of products and not as single product

please if anyone can help me it would be greatly appreciated


Title: Re: how does the add to cart button works?
Post by: ivus on August 09, 2012, 02:38:35 AM
Hi el_carl0s,

You can find the function in the following file

/components/com_virtuemart/helpers/cart.php

The function you want to look at is:



public function setCartIntoSession() {}



Be sure to turn on JOOMLA! DEBUG in the global config as that will allow you to view the session information easily. You want access to view your session (_vm) so that you can be sure your items are being added correctly.

You might also want to use FireBug/Inspector to view the RESPONSES as the ADD TO CART button makes 2 calls, one to place the items into the cart and do all calculations, and the other to pull out the cart items to update the cart info box (X item(s), $X.XX)

I hope this helps.  ;D
Title: Re: how does the add to cart button works?
Post by: el_carl0s on August 09, 2012, 06:34:19 AM
thank you for taking the time to answer, ill put this into practice as soon as i get back to the office