You can start by checking out the link for add to cart.
On my computer it leads to:
(this is the result of $this->getAddToCartUrl($_product); )
This link leads to a controller - In this case: app/code/core/Mage/Checkout/controllers/CartController.php
The code you are looking for is in the addAction() function within that file. You should also look at “addGroupAction()” and “updatePostAction()”
You should note that products aren’t actually added the cart. Rather “quote items” are added the cart (the quote item is created from product item info). When a person checksout, the items become “order items”
You should keep that in mind when you are looking over the code, as you’ll see methods such as “getQuote();”
If you are calling these URL’s via Flash in order to add an item to the cart, make sure you print out the $params so you see all the get/post request info being used in the function - this will allow you to create all the proper variables in ActionScript to pass to Magento to add a product.
//from the addAction function
$params = $this->getRequest()->getParams();
//add this after turning on logging via Admin area
//checkout the results of $params in magento/vars folder