Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/02/2006, 05:16
sneider
 
Fecha de Ingreso: septiembre-2005
Mensajes: 379
Antigüedad: 18 años, 7 meses
Puntos: 0
Gracias figura por contestar.
El codigo es el siguiente:

<?php
function process_card($card_details)
{
// connect to payment gateway or
// use gpg to encrypt and mail or
// store in DB if you really want to

return true;
}

function insert_order($order_details)
{
global $HTTP_SESSION_VARS;

//extract order_details out as variables
extract($order_details);


//set shipping address same as address
if(!$ship_name&&!$ship_address&&!$ship_city&&!$shi p_state&&!$ship_zip&&!$ship_country)
{
$ship_name = $name;
$ship_address = $address;
$ship_city = $city;
$ship_state = $state;
$ship_zip = $zip;
$ship_country = $country;
}

$conn = db_connect();

//insert customer address
$query = "select clienteid from clientes where
name = '$name' and address = '$address'
and city = '$city' and state = '$state'
and zip = '$zip' and country = '$country'";
$result = mysql_query($query);
if(mysql_numrows($result)>0)
{
$cliente_id = mysql_result($result, 0, 'clienteid');
}
else
{
$query = "insert into clientes values
('', '$name','$address','$city','$state','$zip','$count ry')";
$result = mysql_query($query);
if (!$result)
return false;
}
$query = "select clienteid from clientes where
name = '$name' and address = '$address'
and city = '$city' and state = '$state'
and zip = '$zip' and country = '$country'";
$result = mysql_query($query);
if(mysql_numrows($result)>0)
$clienteid = mysql_result($result, 0, 'clienteid');
else
return false;
$date = date('Y-m-d');
$query = "insert into orders values
('', $clienteid, ".$HTTP_SESSION_VARS['total_price'].", '$date', 'PARTIAL', '$ship_name',
'$ship_address','$ship_city','$ship_state','$ship_ zip',
'$ship_country')";
$result = mysql_query($query);
if (!$result)
return false;

$query = "select pedidoid from orders where
clienteid = $clienteid and
amount > ".$HTTP_SESSION_VARS['total_price']."-.001 and
amount < ".$HTTP_SESSION_VARS['total_price']."+.001 and
date = '$date' and
order_status = 'PARTIAL' and
ship_name = '$ship_name' and
ship_address = '$ship_address' and
ship_city = '$ship_city' and
ship_state = '$ship_state' and
ship_zip = '$ship_zip' and
ship_country = '$ship_country'";
$result = mysql_query($query);
if(mysql_numrows($result)>0)
$pedidoid = mysql_result($result, 0, 'pedidoid');
else
return false;


// insert each book
foreach($HTTP_SESSION_VARS['cart'] as $vinosid => $cantidad)
{
$detail = get_book_details($vinosid);
$query = "delete from articulos_pedido where
pedidoid = '$pedidoid' and vinosid = '$vinosid'";
$result = mysql_query($query);
$query = "insert into articulos_pedido values
('$pedidoid', '$vinosid', ".$detail['precio'].", $cantidad)";
$result = mysql_query($query);
if(!$result)
return false;
}

return $pedidoid;
}

?>