include("includes/application_top.php");
$page = 'shopping_cart.php';
if ($HTTP_GET_VARS['action']) {
if ($HTTP_GET_VARS['action'] == 'add_product') { // customer wants to add a product to their shopping cart
$quantity = 1;
$product_exists = 0; // product does not exist in catalog
$product_check = tep_db_query("select id, universal from product where id = '" . $HTTP_GET_VARS['products_id'] . "'");
if (@tep_db_num_rows($product_check)) {
$pcheck = tep_db_fetch_array($product_check);
$product_exists = 1; // product exists in catalog
if (tep_session_is_registered('customer_id')) { // customer is logged in
$product_exists = tep_db_query("select product_id from wishlist where prod_id = '" . $HTTP_GET_VARS['products_id'] . "' and user_id = '" . $customer_id . "'");
if (@tep_db_num_rows($product_exists)) { // product already exists in their basket, so we'll increment the quantity
} else { // the product is not yet in their basket, so we'll add it with a quantity of 1
$date_now = date('Ymd');
tep_db_query("insert into wishlist values ('', '" . $customer_id . "', '" . $HTTP_GET_VARS['products_id'] . "')");
}
header('Location: ' . tep_href_link('wishlist.php', '', 'NONSSL'));
tep_exit();
} else { // customer is not logged in
header('Location: ' . tep_href_link('login.php', 'origin=wishlist', 'NONSSL'));
}
} else {
header('Location: ' . tep_href_link('wishlist.php', '', 'NONSSL'));
tep_exit();
}
} elseif ($HTTP_GET_VARS['action'] == 'remove_product') { // customer wants to remove a product from their shopping cart
if (tep_session_is_registered('customer_id')) {
tep_db_query('delete from wishlist where user_id = '.$customer_id.' and prod_id = ' . $HTTP_GET_VARS['products_id'] . '');
header('Location: ' . tep_href_link('wishlist.php', '', 'NONSSL'));
tep_exit();
}
} elseif ($HTTP_GET_VARS['action'] == 'update_quantity') { // customer wants to update the product quantity in their shopping cart
if (tep_session_is_registered('customer_id')) {
if ($HTTP_POST_VARS['cart_quantity'] > 0) {
header('Location: ' . tep_href_link('wishlist.php', '', 'NONSSL'));
tep_exit();
} else {
tep_db_query("delete from wishlist where id = '" . $HTTP_POST_VARS['cartid'] . "'");
header('Location: ' . tep_href_link('wishlist.php', '', 'NONSSL'));
tep_exit();
}
}
} elseif ($HTTP_GET_VARS['action'] == 'remove_all') { // customer wants to remove all products from their shopping cart
if (tep_session_is_registered('customer_id')) {
tep_db_query("delete from wishlist where user_id = '" . $customer_id . "'");
}
header('Location: ' . tep_href_link('wishlist.php', '', 'NONSSL'));
tep_exit();
}
} else {
?>
$include_file = DIR_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART; include(DIR_INCLUDES . 'include_once.php'); ?>
$location = ' : ' . NAVBAR_TITLE . ''; ?>
=TITLE;?> - My Shopping Cart
$include_file = DIR_INCLUDES . 'header.php'; include(DIR_INCLUDES . 'include_once.php'); ?>
$include_file = DIR_INCLUDES . 'column_left.php'; include(DIR_INCLUDES . 'include_once.php'); ?>
|
|
|
|
|
|
|
if (tep_session_is_registered('customer_id')) {
$check_cart = tep_db_query("select supplier.dba_name as supplier_name, product.id as product_id, product.name as product_name, product.supplier_id as suppid, product.price, product.image, product.supplier_part_number as part_number, wishlist.id as cart_id from wishlist, supplier, product where wishlist.user_id = '" . $customer_id . "' and wishlist.prod_id = product.id and product.supplier_id = supplier.id order by wishlist.id");
while ($check_cart_values = tep_db_fetch_array($check_cart)) {
$price = 0;
$new_price=0;
$price = $check_cart_values['price'];
$products_name = tep_products_name($check_cart_values['supplier_name'], $check_cart_values['product_name']);
list($width, $height, $type, $attr) = @getimagesize(HTTP_SERVER.DIR_CATALOG.'shared/'.$check_cart_values['suppid'].'/'.rawurlencode($check_cart_values['image']));
if($width>$height){
$imgsz = 'width="100"';
}else{
$imgsz = 'height="100"';
}
echo '';
}
} else {
echo ' ' . "\n";
echo ' ' . TEXT_CART_EMPTY . ' | ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . tep_black_line() . ' | ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' | ' . "\n";
echo ' ' . "\n";
}
?>
|
|
|
|
|
|
$include_file = DIR_INCLUDES . 'footer.php'; include(DIR_INCLUDES . 'include_once.php'); ?>
}
?>
$include_file = DIR_INCLUDES . 'application_bottom.php'; include(DIR_INCLUDES . 'include_once.php'); ?>