How to add a product to cart using external link?

Hi guys,



Not sure if I worded the title correctly but here’s the question:



Can you add to cart a product by posting or using a specific link for that product? We have external landing pages and we would like to have it so that users click a BUY button on that landing page and it takes the customer to the store, but with that product already present in the cart and possibly on the cart page itself.



I remember reading something similar to this a while ago and now that I need it, I can’t find it… :frowning:



Thanks for any help provided!

Post #5 in [url]http://forum.cs-cart.com/showthread.php?t=20192&highlight=checkout[/url]

Thanks for the reply! I think that was precisely the post that I saw a while ago although I can’t remember if there was any attachment back then. I just tired this and it won’t work. I’m trying this:



[url]Loading...



and it’s coming up with the green popup saying the cart is empty.

I implemented this a while ago and it works great for me.

You might want to be sure you are using the “product code” and not the “product id” for the $action parameter for the dispatch.

Do I have to extract the contents of the zip? I have uploaded as instructed in the other post and it doesn’t work. Any specific permissions needed?



I was using the product code there, taken out from the product catalogue of the store.

Ok, fantastic. I unzipped it and it now works just perfectly! Thank you!

[quote name='tbirnseth' timestamp='1304551846' post='111601']

Post #5 in [url]http://forum.cs-cart.com/showthread.php?t=20192&highlight=checkout[/url]

[/quote]



Hi There,

I tried to get this add on to work as per the instructions you have given but i seem to have a small bug.



CS-Cart won't allow me to create a .PHP file? It keeps giving me a warning message.

So I created the file; checkout.pre in: (without the file name extension .php)



skins/basic/customer/addons/my_changes/controllers/customer



When trying to use the external link:

?index.php?dispatch=checkout.remote_add.

I am linked back to my store but to the home / landing page and the item is not shown in the cart.

I am using the product code and not product ID in the link url.



I am trying to get this add on to work in community edition version (2.1.3) of CS-cart.



Any suggestions to resolve this would be great.

Thanks

Just to let everyone know, tbirnseth's code still works great in version 3.04. I also made a small change. My client wanted to use it to automatically add a coupon promotion from an email link and then redirect them to the page with the products on it. To do this I changed the last few lines of the code to:




if ($_GET[goto] == '') {
fn_redirect(INDEX_SCRIPT."?dispatch=checkout$_suffix");
}
else {
fn_redirect(INDEX_SCRIPT.$_GET[goto]);
}




Now one can use



http://www.whatever.com/index.php?dispatch=checkout.remote_add.YOURCOUPONCODE&goto=whatver.html