Magento – Cart link or cart Button using magento API

apicartmagento-1.7

I am fetching all the products information outside of the magento installation so I am using soap api. I am unable to fetch cart url on which after clicking on, it will be redirected to my magento installation and it will be added to cart for the user

How do I get the Cart url using magento API. I have tried the url which is dynamic.. however it is redirecting me blank cart. It is showing "Shopping Cart is Empty"

http://example.com/checkout/cart/add/product_id/56/qty/1

I have checked on magento installation it uses the button onclick event

<button onclick="setLocation('http://example.com/checkout/cart/add/uenc/aHR0cDovL2VzaG9wbnNlbGwuY29tL2VzaG9wbnNlbGwuaHRtbD9TSUQ9ZTYyMTJhMzFjY2NmYTU1NzAwMGIxYjNkYTAwODY2Y2I,/product/56/?SID=e6212a31cccfa557000b1b3da00866cb')" class="button btn-cart" title="Add to Cart" type="button"><span><span>Add to Cart</span></span></button>

how this is passing the url

'http://example.com/checkout/cart/add/uenc/aHR0cDovL2VzaG9wbnNlbGwuY29tL2VzaG9wbnNlbGwuaHRtbD9TSUQ9ZTYyMTJhMzFjY2NmYTU1NzAwMGIxYjNkYTAwODY2Y2I,/product/56/?SID=e6212a31cccfa557000b1b3da00866cb'

Thanks 🙂

Best Answer

The link you're describing is created using the users local session. As far as I know it's impossible to access this through the SOAP API.

Instead use the Checkout SOAP API to add a product to cart. Documentation on that can be found here.

This does mean however that you will need to place some of your own code in between that shows the user an add to cart button and calls the API when the users clicks it