";
echo "|
|
View Cart Items Empty Cart |
| Delete |
Product / Order Options |
Unit Price |
- Qty - |
Subtotal | ";
// Main List of Cart Items
// Used to check variables without breaking the site
//mail("dhaupert@ddhsoftware.com","Submit=Cart HTML","pcode=$pcode UID=$UID");
mysqli_select_db($mysqllink,"NewStore");
$result=mysqli_query($mysqllink,"SELECT * FROM CartItems WHERE UserID='$UID' order by CartItemsID");
while ($row = mysqli_fetch_row($result)) {
//mail("dhaupert@ddhsoftware.com","Submit=Cart Item"," CUI=$row[0], CII=$row[1], CIQ=$row[2], OPT=$row[3], CDa=$row[4], CCI=$row[5], Msc=$row[6], UID=$UID");
$CUI=$row[0];
$CII=$row[1];
$CIQ=$row[2];
$OPT=$row[3];
$CDa=$row[4];
$CCI=$row[5];
$Msc=$row[6];
$colo=$colo+1;
if ($colo > 1){
$color = "BGcolor=#EAEAEA";$colo = 0;
}else{
$color = "BGcolor=#ffffff";
}
mysqli_select_db($mysqllink,"NewStore");
$result2=mysqli_query($mysqllink,"SELECT * FROM ItemNew WHERE ItemID='$CII'");
while ($row2=mysqli_fetch_row($result2)) {
$IIS=$row2[1];
$II2=$row2[2];
$IIN=$row2[3];
$IID=$row2[7];
$IIC=$row2[5];
$III=$row2[0];
$IIC=number_format($IIC,"2",".","thousands_sep");
$ST = $CIQ * $IIC;
echo "";
if ($username){
echo " | ";
} else {
echo " | ";
}
echo "$IIN |
$$IIC |
$CIQ |
$$ST |
";
$IIC = $CIQ * $IIC;
if ($pcode){
// Validate Coupon
mysqli_select_db($mysqllink,"NewStore");
$resultu = mysqli_query($mysqllink, "select * from Coupon where cCode = '$pcode'");
while ($rowu=mysqli_fetch_row($resultu)) {
$cID=$rowu[0];
$cCode=$rowu[1];
$cType=$rowu[2];
$cAmt=$rowu[3];
$cBuying=$rowu[4];
$cReq=$rowu[5];
$cAfter=$rowu[6];
$cGets=$rowu[7];
$cExp=$rowu[8];
$cPublic=$rowu[9];
$cNote=$rowu[10];
$Exp = explode("-",$cExp);
$Year = Date("Y");
$Month = Date("m");
$Day = Date("d");
if ($cBuying == $II2 || $cBuying == "ALL"){
$cREF="Priority Code";$TYP=$cType;$AMT=$cAmt;$cMESS="";
}else{
mysqli_select_db($mysqllink,"NewStore");
$resultiB = mysqli_query($mysqllink, "select ItemCode FROM ItemNew where BaseName = '$cBuying' AND Prvt = '0' order by ItemID LIMIT 1");
while ($rowiB=mysqli_fetch_row($resultiB)) {
$cBuyID=$rowiB[0];
}
$cMESS = "Coupon does not match this product Click Here to add this product";$cREF="Priority Code";$TYP="";$cAmt="0.00";$AMT="";
}
if($cReq == "NONE"){
$cREF="Priority Code";$TYP=$cType;$AMT=$cAmt;
}else{
if (!$username){
$cMESS = " Unable to Verify Coupon. Please login on the following page to apply discount.";$cAmt="0.00";$cREF="Priority Code";
}else{
mysqli_select_db($mysqllink,"RegUser");
$resultz = mysqli_query($mysqllink, "select rNum from User where rEmail = '$username'");
$rowz=mysqli_fetch_row($resultz);
$rNum=$rowz[0];
if($cReq == "ANY"){
mysqli_select_db($mysqllink,"RegUser");
$resultya = mysqli_query($mysqllink, "select aNum,aDateR from UserApp where aUser = '$rNum' && (aStatus = 'Normal Sale' || aStatus = 'Freebie' || aStatus = '' || aStatus = 'Retail' || aStatus = 'HDB4UpNormal' || aStatus = 'HDB4FreeUpgrade') LIMIT 1");
$rowya=mysqli_fetch_row($resultya);
$aNum=$rowya[0];
$aDateR=$rowya[1];
if ($aNum){
$cREF="Priority Code";$TYP=$cType;$AMT=$cAmt;
}else{
$cMESS = " - You are Not listed as a registered user or you don't have any valid products under this account.";$cAmt="0.00";$cREF="Priority Code";
}
}elseif($cReq == "ANYHB"){
mysqli_select_db($mysqllink,"RegUser");
$resultyb = mysqli_query($mysqllink, "select aNum,aDateR from UserApp where aUser = '$rNum' && (aStatus = 'Normal Sale' || aStatus = 'Freebie' || aStatus = '' || aStatus = 'Retail' || aStatus = 'HDB4UpNormal' || aStatus = 'HDB4FreeUpgrade') && aApp LIKE 'handbase%' LIMIT 1");
$rowyb=mysqli_fetch_row($resultyb);
$aNum=$rowyb[0];
$aDateR=$rowyb[1];
if ($aNum){
$cREF="Priority Code";$TYP=$cType;$AMT=$cAmt;
}else{
$cMESS = " - You are Not listed as a registered user or you don't have any valid HanDBase products under this account.";$cAmt="0.00";$cREF="Priority Code";
}
}else{
mysqli_select_db($mysqllink,"RegUser");
$resulty = mysqli_query($mysqllink, "select aNum,aDateR from UserApp where aUser = '$rNum' AND aApp = '$cReq'");
$rowy=mysqli_fetch_row($resulty);
$aNum=$rowy[0];
$aDateR=$rowy[1];
if ($aNum){
$cREF="Priority Code";$TYP=$cType;$AMT=$cAmt;
}else{
$cMESS = " - You are Not listed as a registered user or you are not a registered user of the required product.";$cAmt="0.00";$cREF="Priority Code";
}
}
}
}
// this is the expiration codes not-quite working yet
// if ($cEXP){
// if ($Exp[0] < $Year){
// expired
// }else if ($Exp[0] >= $Year && $Exp[1] < $Month){
// expired
// }else if ($Exp[0] >= $Year && $Exp[1] >= $Month && $Exp[2] < $Day)){
// expired
// }
// }
}
}
if ($CIQ > 9 && !$cREF){
echo "| . | Quantity Discount ";
if ($CIQ > 9){$QP = 10;}
if ($CIQ > 19){$QP = $QP+5;}
if ($CIQ > 39){$QP = $QP+5;}
if ($CIQ > 99){$QP = $QP+5;}
if ($CIQ > 249){$QP = $QP+15;}
if ($CIQ > 749){$QP = $QP+10;}
$PDC = $ST * ".$QP";
$IIC = $IIC-$PDC;
$PDC=number_format($PDC,"2",".","thousands_sep");
echo "$QP% | -$PDC | ";
}elseif ($cREF && CIQ < 9){
if ($cType == "percent"){
$cType = "$cAmt% Off";
$PctO = ".$cAmt";
$PctD = $ST * $PctO;
$PctD=number_format($PctD,"2",".","thousands_sep");
$total = $total-$PctD;
echo "| . | Coupon $pcode = $cType | . | -$$PctD | ";
}elseif ($cType == "price"){
$cType = "$$cAmt";
$total = ($total-$ST)+$cAmt;
$total = $total + $ST;
if (!$cMESS){$cMESS = $cNote;}
if (strstr($cMESS,"Discount")){
echo "| . | Coupon $pcode = $cMESS Please login on the following page to apply discount. | . | $$cAmt | ";
}else{
echo "| . | Coupon $pcode = $cMESS | . | $$cAmt | ";
}
}
}
if ($OPT){
echo "| . | ";
if (strstr ($OPT, "|")){
$OPTpieces = explode ("|", $OPT);
$i = 1;
While ($OPTpieces[$i]){
$OPTpieces[$i] = preg_replace("/OS0/","No OS Selected (Select after Purchase and Login)",$OPTpieces[$i]);
$OPTpieces[$i] = preg_replace("/OS1/","Windows",$OPTpieces[$i]);
$OPTpieces[$i] = preg_replace("/OS2/","MAC",$OPTpieces[$i]);
$OPTpieces[$i] = preg_replace("/OS3/","Other",$OPTpieces[$i]);
$OPTpieces[$i] = preg_replace("/OS4/","Web Only",$OPTpieces[$i]);
echo "$OPTpieces[$i] ";
$addonprice = strstr ($OPTpieces[$i], "Add ");
$addonprice = preg_replace("/Add /","",$addonprice);
$addonprice = preg_replace("/]/","",$addonprice);
$aoprice = $aoprice+$addonprice;
$IIC = $IIC+$aoprice;
$addonprice="";
if ($aoprice){
echo " | $$aoprice | "; $aoprice="";
}
$i++;
}
}else{
echo "$OPT ";
$addonprice = strstr ($OPT, "Add ");
$addonprice = preg_replace("/Add /","",$addonprice);
$addonprice = preg_replace("/]/","",$addonprice);
$aoprice = $aoprice+$addonprice;
$IIC = $IIC+$addonprice;
echo "$$aoprice | "; $aoprice="";
}
}
$total = $total+$IIC;
}
echo " | | | ";
}
if (!$total){ echo "| Cart is Empty | ";}
echo "| Total: | ";
$total=number_format($total,"2",".","thousands_sep");
echo"$$total | ";
// Upsell here
echo "
| Associated Offers | ";
mysqli_select_db($mysqllink,"NewStore");
$resultz=mysqli_query($mysqllink,"SELECT ItemID FROM CartItems WHERE UserID='$UID' order by CartItemsID");
while ($rowz = mysqli_fetch_row($resultz)) {
$CII=$rowz[0];
mysqli_select_db($mysqllink,"NewStore");
$resulty=mysqli_query($mysqllink,"SELECT BaseName FROM ItemNew WHERE ItemID='$CII'");
while ($rowy=mysqli_fetch_row($resulty)) {
$IBN=$rowy[0];
mysqli_select_db($mysqllink,"NewStore");
$resultx = mysqli_query($mysqllink, "select * from UpSell WHERE ListApp='$IBN' && upPrivate='0'");
while ($rowx=mysqli_fetch_row($resultx)) {
$upID=$rowx[0];
$upName=$rowx[3];
$upDesc=$rowx[4];
$upPrice=$rowx[5];
$colo=$colo+1;
if ($colo > 1){
$color = "BGcolor=#EAEAEA";$colo = 0;
}else{
$color = "BGcolor=#ffffff";
}
if ($username){
echo "$upName: $upDesc | $$upPrice [Add Now] | ";
} else {
echo "$upName: $upDesc | $$upPrice [Add Now] | ";
}
}
}
}
echo " ";
if ($total > "0"){
echo " |