Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to pass product to shopping cart? 
 
webman
Jr. Member
 
Total Posts:  4
Joined:  2008-06-24
 

I have a tshirt site that allows users to design their own shirts via a stand-alone flash app that is embedded on a magento page.  I want allow the customer to checkout via Magento.  Is there a direct URL call that would add a t-shirt to the shopping cart so that they can then edit the quanity and checkout all from Magento?  Is this possible?  How would I do it?

 
Magento Community Magento Community
Magento Community
Magento Community
 
webman
Jr. Member
 
Total Posts:  4
Joined:  2008-06-24
 

Any help on this would be greatly appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
keyur
Jr. Member
 
Total Posts:  9
Joined:  2008-09-13
 

very interested in this as well, would be a great feature.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

You can start by checking out the link for add to cart.
On my computer it leads to:

http://localhost/magento/index.php/checkout/cart/add/uenc/L35DaHJpcy9tYWdlbnRvL2luZGV4LnBocC9jYXRhbG9nL2NhdGVnb3J5L3ZpZXcvaWQvMw,,/product/1/

(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
Mage::log($params);
//checkout the results of $params in magento/vars folder
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top