Forum Moderators: coopster
I want to put together a simple "cart" that will store what the user clicks to buy (and quantity), and a few other bits into a cookie, which can all be accessed in a new window, modified, what have you, and the user then select the payment method (PayPal/NoChex/etc.) and the information be passed to whichever.
Since this is a little long winded for something that needs to be simple, here's a nice diagram :)
User clicks item to buy
¦
¦
Information passed to cookie
¦
¦
User looks in "cart"
¦
¦
Cart reads cookie and displays info.
¦
¦
User selects payment method
¦
¦
Info transfered to payment processor (PayPal et al)
I posted here in PHP because it looks like the most appropriate language (Javascript is often disabled, especially of late), though if there is something more appropriate please say.
I *think* this should be fairly simple(?). I'm not after a complete solution (I've poked round Mals-e etc.) I just want the basics of setting cookies, passing the info to different processors, etc.
Huge TIA :)
James.
Basic cookie syntax from [php.net:...]
bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])
i.e.
setcookie("testcookie",$somevalue);
Once the cookie has been set, you can access it using the $_COOKIE environment variable.
i.e.
$thisvalue=$_COOKIE['testcookie'];
results in:
$thisvalue=$somevalue;
which can then be passed via CGI/email/FTP, etc. to another server.
On the "order" page:
<?php
session_start();
$_SESSION['itemID']=$quantity;
?>
In the cart summary:
<?php
session_start();
echo $_SESSION['itemID'];
?>
When you're debugging, you can look at the contents of the session with this:
print_r($_SESSION);
It's also easy to populate a "checkout" form with all the session items, with a submit button that passes your cart into PayPal/NoChex/etc.
good luck!