I have a small issue with a website i'm writing and i hope for anyone's help.
I'm implementing a simpleCart in a website, the buying process is pretty simple.
What i wish to do is to proceed the user to a page where he can fill in a form and then proceed to checkout. (i don't want users to create an account and everything just for the sake of buying a single item)
But i can't seem to push the simplecart value to that other page (i only need the total price).
what i tried is the following:
- store total price in PHP session
- store total price in Javascript Cookie
- create new checkout event on simplecart to redirect the user to a custom page where he can fill the form and then checkout for real.
i had no luck with all of these and i wold appreciate any ideas or help.
here's some of the code i already tried: the simple cart total can be displayed either by adding: or (javas) this.returnFormattedPrice(tempItem.getValue('price') )
First i tried storing the out put in php sessions:
on Page1:
<?php
session_start();
$_SESSION['variable_name'] = '<div class="simpleCart_total"></div>';
?>
on Page 2:
<?php
session_start();
echo $_SESSION['variable_name'];
?>
Second i tried using a javas cookie:
here's the script code:
`// JavaScript Document
function getCookie(NameOfCookie)
{
if (document.cookie.length > 0)
{
begin = document.cookie.indexOf(NameOfCookie+"=");
if (begin != -1)
{
begin += NameOfCookie.length+1;
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); }
}
return null;
}
function setCookie(NameOfCookie, value, expiredays)
{
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
function delCookie (NameOfCookie)
{
if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
} `
on page 1 i would set the cookie and on page 2 i would read it
but setting it up with both :
<div class="simpleCart_total"></div>
or (javas) this.returnFormattedPrice(tempItem.getValue('price') )
didn't work ( it would'nt store the total price)
so if anyone has a simpler approach i would appreciate it.
thanks in advance
Ahmad