Adding product to basket using HTTP GET call

Hi guys!

I’m new to CS-Cart and just got everything installed and starting to play with it. I would like to create some very simple store flow, that will allow me to easily add a product to the basket, and once the user adds the product to the basket he is also taken to the page showing all the products in his basket and the user can proceed to checkout right away from there.

I managed to get all of this mods implemented and now playing some more with the tpls design.

One small thing that I failed to find - how can I build a simple URL with GET call to pass the product ID I wish to add?

Currently, the only way I managed to find to add products to the basket is by using a POST call via form with some hidden params, something like this:

<br />
<form action="store/index.php" method="post" name="product_form_29778" style="display: inline;"><br />
<input name="result_ids" value="cart_status,wish_list" type="hidden"><br />
<input name="redirect_url" value="store/index.php?dispatch=checkout.cart" type="hidden"><br />
<input name="product_data[29778][product_id]" value="29778" type="hidden"><br />
<input type="image" src="pictures/buttons/button_get_it_now.png" name="dispatch[checkout.add..29778]" onsubmit="submit-form();"><br />
</form><br />

```<br />
<br />
I tried finding a simpler way to add a single product to the basket with a simple GET call, but with no luck.<br />
<br />
Any help will be greatly appreciated! Many thanks for the help!<br />
<br />

Your url would look like:


to add the product to the cart (note the 2 dots ‘…’) but then you will need another redirect of:


to actually take the user to the cart.

Assuming you are doing this from somewhere outside the cart. Otherwise you should just use:

{include file=“buttons/checkout.tpl”}

Many thanks tbirnseth for your assistance with this! :slight_smile:

Unfortunately I didn’t manage to get this working by calling the two files you mentioned above. I tried performing the first call with PHP curl and then redirecting the user to the second page with the PHP header, but apparently the first call didn’t had any effect I’m afraid.

However, the good news are that I managed to get this working quickly with the solution you posted here:


(Your reply at post #5)

I’m now sending the user from our main site (which is external to the store) using a link like this:


And then user is directly displayed with his current basket page, listing all products the user currently have in his basket.

In the thread above, you posted this solution as the right solution to direct users to the store from external sites. Do you see any problem using this in the same way I’m using it right now? That is - using it from within the same web-site to direct the user to the store with one single link?

Is there a better way to achieve this result, or this is a proper solution for this need?

Many thanks for the time and help! :slight_smile: