\n"; echo "
\n"; echo "

Items In Your Shopping Cart

\n"; echo "
\n"; echo "
\n"; echo "
\n"; ConnectDB(); //echo "\n\n\n\n"; //echo "\n"; //echo "\n\n"; // Add to cart from Large Item mysql_connect("$DBHost","$DBUser","$DBPass"); mysql_select_db("$DB"); $result=mysql_query("select * from $items where id='$sku_id'"); $row = mysql_fetch_row($result); echo "\n\n\n\n"; if ($command=="calc" || $add2cart=="OrderNow") { // Verify SKU Exists $result=mysql_query("select * from items where id='$sku_id' and item_active='1'"); $row = mysql_fetch_row($result); if($sku_id==$row[0]) { $company_id=$row[15]; $shipping=$row[21]; } else { $add_cart_error=2; } // Find Multi Price echo "\n\n"; if ($price_id!="") { $result=mysql_query("select * from multi_price where id='$price_id'"); $row = mysql_fetch_row($result); if ($row[4]!=1) { $base_price=$row[3]*$quantity; } else { $orig_price_id=$price_id; $result2=mysql_query("select * from multi_price where item_id='$sku_id' and top_qty>'$quantity' order by top_qty asc"); $temp_count=mysql_num_rows($result2); if ($temp_count>0) { $row2 = mysql_fetch_row($result2); $price_id=$row2[0]; $base_price=$row2[3]*$quantity; if ($orig_price_id!=$price_id) { echo "
Adjusted Quantity Pricing: $$row2[3] x $quantity

\n"; } } else { $result2=mysql_query("select * from multi_price where item_id='$sku_id' order by top_qty desc"); $row2 = mysql_fetch_row($result2); $price_id=$row2[0]; $base_price=$row2[3]*$quantity; if ($orig_price_id!=$price_id) { echo "
Adjusted Quantity Pricing: $$row2[3] x $quantity

\n"; } } } } // Main Price is set, so check options. echo "\n\n\n"; echo "\n\n\n"; if ($option_count>0) { echo "\n\n\n"; for ($i=0;$i<$option_count;$i++) { echo "\n\n\n"; $temp_option=explode("|",$option_value[$i]); echo "\n\n\n"; if ($temp_option[2]!="") { $item_price=$item_price+$temp_option[2]; } $cart_option_name[$i]=$temp_option[0]; $cart_option_id[$i]=$temp_option[1]; $cart_option_value[$i]=$temp_option[3]; } //$item_price=$item_price+$base_price; //$price_shown=$item_price; } $item_price=$item_price+$base_price; $price_shown=$item_price; if ($add2cart=='OrderNow') { if ($quantity=="" || $quantity==0) {$quantity=1;} if ($price_shown=="0.00" || $price_shown=="" || $price_shown=="0") { $add_cart_error=1; } $shipping_price=$quantity*$shipping; $shipping_price=sprintf("%0.2f",$shipping_price); $final_price=$quantity*$price_shown; $final_price=sprintf("%0.2f",$final_price); echo "\n\n"; $date_now=time(); if ($add_cart_error==0) { mysql("$DB", "INSERT INTO cart (id,cust_id,sku_id,quantity,from_multi,final_price,aff_id,date_in) values ('','$cart_id','$sku_id','$quantity','$price_id','$final_price','$aff_id','$date_now')") or die(mysql_error()); $result=mysql_query("select * from cart where cust_id='$cart_id' and sku_id='$sku_id' and date_in='$date_now'"); $row = mysql_fetch_row($result); $cart_item_id=$row[0]; // Section off information for options side of cart. if ($option_count>0) { for ($i=0;$i<$option_count;$i++) { if ($option_value[$i]!="") { mysql("$DB", "INSERT INTO cart_options (id,cust_id,sku_id,item_option_id,item_option_value,cart_id,date_in) values ('','$cart_id','$sku_id','$option_id[$i]','$cart_option_id[$i]','$cart_item_id','$date_now')"); } } } //echo "
Item Added To Cart
\n"; //$item_counter=0; //$result=mysql_query("select quantity from cart where cust_id='$cart_id'"); //while ($row = mysql_fetch_row($result)) { // $item_counter++; //} //echo "\n"; //if ($item_counter==1) { // echo "
You have $item_counter item in your cart. View Cart

"; //} elseif ($item_counter>1) { // echo "
You have $item_counter items in your cart. View Cart

"; //} //echo "
\n"; } else { echo "
Item NOT Added To Cart
\n"; echo "
$add_cart_error_name[$add_cart_error]
\n"; } } } if ($command=='modify') { echo "
Cart Modification Status: \n"; mysql_connect("$DBHost","$DBUser","$DBPass"); mysql_select_db("$DB"); for ($i=0;$i<$count;$i++) { $d=$i+1; if ($value[$d]==0) { mysql("$DB", "DELETE FROM cart where id='$value[$i]' and cust_id='$cart_id'"); mysql("$DB", "DELETE FROM cart_options where cart_id='$value[$i]' and cust_id='$cart_id'"); } else { $result=mysql_query("select * from cart where id='$value[$i]' and cust_id='$cart_id'"); $row = mysql_fetch_row($result); $single_price=$row[5]/$row[3]; $single_price=sprintf("%0.2f",$single_price); $new_price=$single_price*$value[$d]; $new_price=sprintf("%0.2f",$new_price); mysql("$DB", "UPDATE cart SET quantity='$value[$d]', final_price='$new_price' where id='$value[$i]'"); } $i++; } //mysql("$DB", "DELETE FROM $cart where id='$id' and quantity='0'"); echo "Cart Modified\n"; echo "

\n"; } if ($command=='remove') { echo "
Cart Modification Status: \n"; mysql_connect("$DBHost","$DBUser","$DBPass"); mysql_select_db("$DB"); mysql("$DB", "DELETE FROM cart where id='$ss_cart_id'"); mysql("$DB", "DELETE FROM cart_options where cart_id='$ss_cart_id'"); echo "Item Removed\n"; echo "

\n"; } if ($command=='empty') { echo "
Empty Cart:\n"; $kill_time=time()-86400; mysql_connect("$DBHost","$DBUser","$DBPass"); mysql_select_db("$DB"); mysql("$DB", "DELETE FROM cart where cust_id='$cart_id'"); mysql("$DB", "DELETE FROM cart_options where cust_id='$cart_id'"); mysql("$DB", "DELETE FROM cart where date_in<'$kill_time'"); mysql("$DB", "DELETE FROM cart_options where date_in<'$kill_time'"); mysql("$DB", "DELETE FROM cart where cust_id=''"); mysql("$DB", "DELETE FROM cart_options where cust_id=''"); echo "Cart Emptied\n"; } mysql_connect("$DBHost","$DBUser","$DBPass"); mysql_select_db("$DB"); $result=mysql_query("select * from cart where cust_id='$cart_id'"); $rowt = mysql_fetch_row($result); if (strlen($rowt[0])!=0) { //echo "

Items In Your Cart:


\n"; $base_shipping=0; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $count=0; $item_count=0; $result=mysql_query("select * from cart where cust_id='$cart_id'"); while ($row = mysql_fetch_row($result)) { echo ""; echo ""; $result2=mysql_query("select * from items where id='$row[2]'"); $price=sprintf("%0.2f",$row[5]); while ($row2 = mysql_fetch_row($result2)) { $sku=$row2[1]; echo "\n"; echo "\n"; echo "\n"; echo "\n"; //echo "\n"; $temp_cat=$row2[11]; if($row[6]!=0) {$base_shipping=$base_shipping+$row[6];} } $count++; //$item_total= $price*$row[2]; //$item_total=sprintf("%0.2f",$item_total); echo "\n"; echo "\n"; $subtotal=$subtotal+$price; $subtotal=sprintf("%0.2f",$subtotal); $count++; $sku_list[$item_count]=$row[1]; $sku_cat_list[$item_count]=$temp_cat; if ($row[2]>1) { for ($f=1;$f<=$row[2];$f++) { $next_item=$item_count+$f; $sku_list[$next_item]=$row[1]; $sku_cat_list[$next_item]=$temp_cat; $item_count++; } } $item_count++; /// Check for and display Multiprice Name if it has any. if ($row[4]!="0") { $result6=mysql_query("select * from multi_price where id='$row[4]'"); $row6 = mysql_fetch_row($result6); echo "\n"; } /// Check for and display item options if it has any. //$result3=mysql_query("select * from cart_options where cust_id='$cart_id' and sku_id='$row[2]' and cart_id='$row[0]'"); //while ($row3 = mysql_fetch_row($result3)) { // $result4=mysql_query("select * from item_options where id='$row3[3]'"); // $row4 = mysql_fetch_row($result4); // $result5=mysql_query("select * from item_options_value where id='$row3[4]'"); // $row5 = mysql_fetch_row($result5); // echo "\n"; // // } } $item_count=$item_count-1; echo "\n"; echo "\n"; $original_subtotal=$subtotal; if ($base_shipping!=0) { $subtotal=$subtotal+$base_shipping; $base_shipping=sprintf("%0.2f",$base_shipping); echo "\n"; echo "\n"; } if ($use_tax==1) { $tax=$subtotal*$tax_amount; $subtotal=$subtotal+$tax; $tax=sprintf("%0.2f",$tax); echo "\n"; echo "\n"; } if ($use_discount==1) { $discount=$subtotal*$discount_amount; $subtotal=$subtotal+$discount; $discount=sprintf("%0.2f",$discount); echo "\n"; echo "\n"; } $subtotal=sprintf("%0.2f",$subtotal); if ($subtotal!=$original_subtotal) { echo "\n"; echo "\n"; } echo "
X
Item #
Item Name
Qty
Total
X$row2[1]$row2[4]"; // Show Options with Item Name /// Check for and display item options if it has any. $result3=mysql_query("select * from cart_options where cust_id='$cart_id' and sku_id='$row[2]' and cart_id='$row[0]'"); while ($row3 = mysql_fetch_row($result3)) { $result4=mysql_query("select * from item_options where id='$row3[3]'"); $row4 = mysql_fetch_row($result4); $result5=mysql_query("select * from item_options_value where id='$row3[4]'"); $row5 = mysql_fetch_row($result5); echo "
  $row4[2]: $row5[2]\n"; } echo "
$$price
$$price
   $sku: $row6[2] 
   $sku: $row4[2]: $row5[2] 
Subtotal:
$$subtotal
Base Shipping:
$$base_shipping
Tax:
$$tax
Discount:
$$discount
Grand Total:
$$subtotal
\n"; echo "
"; echo ""; //include("other/view_cart_text.php"); echo "
 \n"; echo "
"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "

\n"; echo "
View Cart | "; echo "Continue Browsing


\n"; } else { echo "

Your Cart is Empty!

\n"; echo "

View Cart | "; echo "Continue Browsing


\n"; } echo "
\n"; echo "\n"; //echo "\n"; commonFooter("$user_id"); ?>