include_once('mysql.inc');
include_once("auth.inc");
$seo_title = "View Cart | SuperSeller Tools";
$seo_description = "";
$seo_keywords = "";
$same_as_billing = "Y";
$PRODUCT_PACKAGES = array('190'=>true,'191'=>true,'189'=>true,'188'=>true);
if ($do == "login") {
$q = "SELECT * from SST_accounts where email='$email' and password='$password'";
$results = mysql_query($q);
if (mysql_num_rows($results) > 0) {
$row = mysql_fetch_array($results);
extract($row);
$time = time() + 60 * 60 * 24 * 30 * 12;
setcookie("access_cookie", $accounts_id, $time, "/");
$logged_id = $accounts_id;
}
if (!$logged_id)
{
$login_error = "We could not match an account. Please try again.";
}
}
if ($submit_shipping)
{
if (!$email && !$logged_id)
$error = "Please enter your Email.";
if (!$firstname)
$error = "Please enter your First Name.";
if (!$lastname)
$error = "Please enter your Last Name.";
if (!$address)
$error = "Please enter your Address.";
if (!$city)
$error = "Please enter your City.";
if (!$phone)
$error = "Please enter your Phone.";
$q = "SELECT * FROM zipcodes WHERE ZIP_CODE='$postal_code'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$ZIP_CODE = $row["ZIP_CODE"];
if ($ZIP_CODE && $country == "US")
{
if ($country != "US" && $country != "CA")
$country = "US";
$q = "select * from zipcodes where state='$state' and ZIP_CODE='$postal_code'";
$results = mysql_query($q);
$amount = mysql_num_rows($results);
if ($amount < 1) {
$error .= "- There seems to be a problem with your postal code.";
}
}
$q = "SELECT * from shipping_countries where country_code='$country'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$need_postal_code = $row["need_postal_code"];
if (($need_postal_code == "Y") && (!$postal_code)) {
$error = "You must enter a postal code for the country you selected.";
}
if ($country == "US" && !$state)
$error = "You must select a state.";
$email = htmlspecialchars($email, ENT_QUOTES);
$company = htmlspecialchars($company, ENT_QUOTES);
$contact = htmlspecialchars($contact, ENT_QUOTES);
$address = htmlspecialchars($address, ENT_QUOTES);
$city = htmlspecialchars($city, ENT_QUOTES);
if (!$logged_id)
{
if (!$error)
{
$postal_code = str_replace(" ", "", $postal_code);
if ($country == "US")
{
$postal_code = substr($postal_code, 0, 5);
}
if (!$wholesale_percentage) $wholesale_percentage = "0";
if(!$password) $password = time();
$q = "INSERT INTO SST_accounts SET firstname='$firstname',lastname='$lastname',address='$address',city='$city',state='$state',postal_code='$postal_code',password='$password',email='$email',country='$country',created_date=NOW(),lastlogindate=NOW(), phone='$phone', company='$company',company_info='$company_info',elements='$elements', wholesale='n',contact='$firstname $lastname',wholesale_percentage='$wholesale_percentage'";
mysql_query($q);
$accounts_id = mysql_insert_id();
$time = time() + 60 * 60 * 24 * 30 * 12;
setcookie("access_cookie", $accounts_id, $time, "/");
$logged_id = $accounts_id;
}
}
if (!$error)
{
include_once("cc_info.php");
die;
}
}
if ($do == "addtocart")
{
$tmp = $quantity . "_" . $registry_products_id;
$_SESSION["prod-$products_id-$products_sizes_id-$products_colors_id-$package_type"] = $tmp;
if($products_id == 192)
{
$_SESSION["donation-$products_id"] = $donation_amount;
}
$added_products_id = $products_id;
}
elseif ($do == "remove")
{
$_SESSION[$item] = 0;
unset($_SESSION[$item]);
}
elseif ($do == "updatecart")
{
while(list($k, $v) = each($_POST))
{
$bits = array();
$bits = explode("_newquant", $k);
if ($bits[1])
{
$elements = explode("_", $k);
$sess_var = $elements[0];
$tmp = $_SESSION["prod-$sess_var"];
$_SESSION["prod-$sess_var"] = 0;
$parts = explode("_", $tmp);
$registry_products_id = $parts[1];
$newtmp = $v . "_" . $registry_products_id;
$_SESSION["prod-$sess_var"] = $newtmp;
}
}
}
reset($_SESSION);
while (list($k, $v) = each($_SESSION))
{
$product_color = "";
$onsale = "n";
$item = $k;
$parts = explode("-", $k);
$products_id = $parts[1];
$products_sizes_id = $parts[2];
$products_colors_id = $parts[3];
$package_type = $parts[4];
$elements = explode("_", $v);
$quantity = $elements[0];
if($parts[0] == "donation") continue;
if ($products_id)
{
$q = "select * from SST_products where products_id='$products_id'";
$res = mysql_query($q);
$row = mysql_fetch_array($res);
extract($row);
if ($wholesale == "y")
{
$retail_price = $professional_price;
}
$weight = $weight * $quantity;
$total_weight = $total_weight + $weight;
$found = "n";
for ($y = 1; $y <= 10; $y++)
{
if (is_file("productphotos/$products_id-$y-og.jpg"))
{
$thepic = "productphotos/$products_id-$y-og.jpg";
$found = "y";
break;
}
}
if($products_colors_id)
{
$q = "SELECT * from SST_products_colors where products_colors_id='$products_colors_id'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$product_color = $row["product_color"];
$option_retail_price = $row["option_retail_price"];
if($option_retail_price > 0) $retail_price = $option_retail_price;
$prooption_retail_price = $row["prooption_retail_price"];
if($wholesale == "y" && $prooption_retail_price > 0)
{
$retail_price = $prooption_retail_price;
}
for($i=1;$i<=3;$i++)
{
$tmp = "productphotos/opt-$products_id-$products_colors_id-$i-og.jpg";
if (is_file($tmp))
{
$thepic = $tmp;
}
}
}
$photo_string = "";
$photo_string.= "";
if($product_color)
{
$product_name = "$product_name ($product_color)";
}
$tmpname = $products_id . "-" . $products_sizes_id . "-" . $products_colors_id . "-" . $package_type . "_newquantity";
$website_price = $retail_price * $quantity;
if($products_id == 192)
{
$website_price = $_SESSION["donation-$products_id"];
}
$website_price = number_format($website_price, 2, '.', '');
if($onsale != "y")
{
$discountsubtotal = $discountsubtotal + $website_price;
}
$subtotal = $subtotal + $website_price;
$cart_rows.= "