Ver Mensaje Individual
  #9 (permalink)  
Antiguo 07/07/2004, 11:48
tmh4mail
 
Fecha de Ingreso: junio-2004
Mensajes: 71
Antigüedad: 19 años, 10 meses
Puntos: 1
Xcorpion.

Este es el codigo. Solo voy a postear 3 Items. El Total de los Items son 141 si quieres puedes mirar la page que puse para una demostracion.
http://www.themailinghouse.com/demo/cart.php

////////EL Code es//////////
<?php
session_start();
$username='user';
$password='pass';
$hostname='local';
$databasename='db';
$header = "header.html";
$footer = "footer.html";
$returnpage = "/demo/demo.php";
$youremail = "[email protected]";
$mode = "BOTH";


function doFormError($errString) {

include($header);

echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
echo "$errString<BR><BR>\n";
echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>";

include($footer);

exit;
}

function doError($errString) {

include($header);

echo "$errString<BR><BR>\n";

include($footer);

exit;
}

$idno= $_POST['idno'];
$first= $_POST['first'];
$last= $_POST['last'];
$today= $_POST['today'];
$need= $_POST['need'];
$s_first= $_POST['s_first'];
$s_last= $_POST['s_last'];
$s_addr= $_POST['s_addr'];
$s_addr2= $_POST['s_addr2'];
$s_city= $_POST['s_city'];
$s_state= $_POST['s_state'];
$s_zip= $_POST['s_zip'];
$s_phone= $_POST['s_phone'];
$s_fax= $_POST['s_fax'];
$s_email= $_POST['s_email'];
$fedex= $_POST['fedex'];
$ItemQA031= $_SESSION['sessItemQA031'];
$Desc1= $_SESSION['sessDesc1'];
$Qty1= $_SESSION['sessQty1'];
$ItemQA033= $_SESSION['sessItemQA033'];
$Desc2= $_SESSION['sessDesc2'];
$Qty2= $_SESSION['sessQty2'];
$ItemQA058= $_SESSION['sessItemQA058'];
$Desc3= $_SESSION['sessDesc3'];
$Qty3= $_SESSION['sessQty3'];

if (($first == "") || ($last == "") || ($idno == "") || ($need == "")) {
doFormError("I'm sorry, but it appears that you forgot to fill in a required field. Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
exit;
}

if( !(ereg("^(.+)@(.+)\\.(.+)$",$s_email)) ) {
doFormError("You submitted an invalid email address. Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
exit;
}

$conection = @mysql_connect($hostname, $username, $password);

mysql_select_db($databasename);

if( $Qty1 ) mysql_query(" UPDATE qaninv SET qtys='$Qty1' ,stock=stock-$Qty1 WHERE itemid='$ItemQA031'");
if( $Qty2 ) mysql_query(" UPDATE qaninv SET qtys='$Qty2' ,stock=stock-$Qty2 WHERE itemid='$ItemQA033'");
if( $Qty3 ) mysql_query(" UPDATE qaninv SET qtys='$Qty3' ,stock=stock-$Qty3 WHERE itemid='$ItemQA058'");

// CLOSE CONNECTION --->
mysql_close($conection);


$invoice = date ("ymdHis");
$today = date ("l, F jS Y");
$strMessageBody = "";
$strMessageBody .= "A new order has been received. A summary of this order appears below.\n";
$strMessageBody .= "\n";
$strMessageBody .= "Order Date: $today \n";
$strMessageBody .= " \n";
$strMessageBody .= "Invoice #: $idno$invoice \n";
$strMessageBody .= " \n";
$strMessageBody .= "Qantas Rep: \n";
$strMessageBody .= "----------------- \n";
$strMessageBody .= " $first $last \n";
$strMessageBody .= " Need By: $need \n";
$strMessageBody .= " FedEx #: $fedex \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Ship To: \n";
$strMessageBody .= "--------------- \n";
$strMessageBody .= " $s_first $s_last \n";
$strMessageBody .= " $s_addr $s_addr2 \n";
$strMessageBody .= " $s_city, $s_state $s_zip \n";
$strMessageBody .= " $s_phone \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Qty Product ID Product Name\n";
$strMessageBody .= "================================================= ==================== \n";
if( $Qty1 ) {$strMessageBody .= "$Qty1 $ItemQA031 - $Desc1 \n";}
if( $Qty2 ) {$strMessageBody .= "$Qty2 $ItemQA033 - $Desc2 \n";}
if( $Qty3 ) {$strMessageBody .= "$Qty3 $ItemQA058 - $Desc3 \n";}
$strMessageBody .= "================================================= ==================== \n";
//$strMessageBody .= "SUBTOTAL: $SUBTOTAL \n";
//$strMessageBody .= "TOTAL: $TOTAL \n";
//$strMessageBody .= "\n";
//$strMessageBody .= "FREIGHT: $SHIPPING \n";
$strMessageBody .= "\n\n";
$strMessageBody .= "Comments: \n";
$strMessageBody .= "------------------ \n";
$strMessageBody .= "$comment \n";
$strMessageBody .= " \n";


if( $mode == "BOTH" || $mode == "EMAIL") {
$mailheaders = "From: $s_email\r\n";
$mailheaders .="X-Mailer: PHP Mail generated by:The Mailing House Inc.®\r\n";
$subject = "New Online Order";
mail($youremail, $subject, $strMessageBody, $mailheaders);


//# Send email conformation to the customer.....
$mailheaders = "From: $youremail\r\n";
$mailheaders .="X-Mailer: PHP Mail generated by:The Mailing House Inc.®\r\n";
$subject = "Order Confirmation";
mail($s_email, $subject, $strMessageBody, $mailheaders);
}


echo "<h2>Thank you</h2>";
echo "Thank you for your oline order. You will receive a confirmation email of your order ";
echo "momentarily. Please contact us at $youremail if you have any questions or concerns.";
echo "<P>";
echo "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
echo "<P>";


?>


lo que estoy haciendo es cuando ordenan alguna orden. el checkout.php manda un email de confirmacion a el cliente y otro a la company donde trabajo. Al mismo tiempo hace update al db. es donde estoy restando stock=stock-$Qtyx asi nuestro cliente puede tener haceso al inventario. y puede saber que tanto se encunetra habalible.


Saludos.