Kal
01-15-2007, 12:48 PM
guys im trying to fix a couple of bugs in my shopping cart application, basically when you add a product into the cart and hit refresh the same product gets added again depending on how many times you refresh.
i have the following code but getting erros on the highlighted lines.
any help would be great.
switch ($action)
{
case 'add':
$last_add = $session->get('last');
if (!$last_add)
{
if ($cart)
{
$cart .= ','.$_GET['product_id'];
}
else
{
$cart = $_GET['product_id'];
}
}
else
{
$last_arr = explode('|',$last_add);
$last_item = $last_arr[0];
$last_time = $last_arr[1];
if ($product_id == $last_item && ($last_time - time() < 300))
{
}
else
{
if ($cart)
{
$cart .= ','.$_GET['product_id'];
}
else
{
$cart = $_GET['product_id'];
}
}
}
$session=>set('last',$product_id.'|'.time());
break;
i have the following code but getting erros on the highlighted lines.
any help would be great.
switch ($action)
{
case 'add':
$last_add = $session->get('last');
if (!$last_add)
{
if ($cart)
{
$cart .= ','.$_GET['product_id'];
}
else
{
$cart = $_GET['product_id'];
}
}
else
{
$last_arr = explode('|',$last_add);
$last_item = $last_arr[0];
$last_time = $last_arr[1];
if ($product_id == $last_item && ($last_time - time() < 300))
{
}
else
{
if ($cart)
{
$cart .= ','.$_GET['product_id'];
}
else
{
$cart = $_GET['product_id'];
}
}
}
$session=>set('last',$product_id.'|'.time());
break;