assign("use_CVV2",($use_CVV2_res["param09"]=="y" ? TRUE : FALSE)); $smarty->assign("ckfr_login",$use_CVV2_res["ckfr_login"]); // Making one call for this data. I know name makes no sense. session_register("cart"); session_register("intershipper_rates"); session_register("intershipper_recalc"); $intershipper_recalc = "Y"; session_register ("in_checkout"); function cmp1 ($a, $b) { return $a["orderby"]>$b["orderby"]; } if ($in_checkout == "Y") { header ("Location: $http_location/payment/payment_cc.php?mode=continue"); exit; } #$intershipper_recalc = "Y"; # # $order_secureid (for security reasons) # session_register("order_secureid"); # # Register member if not registerred yet # (not a newbie - do not show help messages) # $smarty->assign("register_script_name","cart.php"); require "../include/register.php"; if ($auto_login) { header("Location: cart.php?mode=checkout®istered="); exit; } if (!empty($login)) $userinfo = func_userinfo($login, $current_area); # # Add to cart # if($mode=="add" && $productid!="") { $added_product=func_select_product($productid, $user_account['membership']); # # Add to cart amount of items that is not much than in stock # $amount = array_pop(func_query_first("select least('$amount',avail) from products where productid='$productid'")); if ($productid && $amount) { if ($amount < $added_product[min_amount]) { header ("Location: error_message.php?access_denied"); exit; } # # Do addition to cart # With options # $options=array(); if($product_options) { if ($active_modules["Product_Options"]) func_check_product_options ($productid, $product_options); foreach($product_options as $key=>$product_option) { $options[]=array("optclass"=>$key,"optionindex"=>$product_option); } } $found = false; if ($cart["products"]) { foreach ($cart["products"] as $k=>$v) { if (($v["productid"] == $productid) and (!$found) and ($v["options"] == $options)) { $found = true; $cart["products"][$k]["amount"] += $amount; } } } # # price value is defined by customer if administrator set it to '0.00' # if (!$found) $cart["products"][]=array("productid"=>$productid,"amount"=>$amount, "options"=>$options, "price"=>$price); $intershipper_recalc = "Y"; } } if (!func_is_cart_empty($cart)) { $products = func_products_in_cart($cart, $userinfo["membership"]); $is_free_shipping = "N"; if ($products) { $is_free_shipping = "Y"; foreach ($products as $v) { if ($v ["free_shipping"] != "Y") $is_free_shipping = "N"; } } $smarty->assign ("is_free_shipping", $is_free_shipping); if($active_modules["Subscriptions"]) { include_once "../modules/Subscriptions/subscription.php"; } } if ($mode=="delete" && $productindex!="") { # # Delete product from cart # if($active_modules["Advanced_Statistics"]) @include "../modules/Advanced_Statistics/prod_del.php"; array_splice($cart["products"],$productindex,1); $intershipper_recalc = "Y"; header("Location: cart.php"); exit; } # # If current shipping is empty set it to default (first in shipping array) # $smarty->assign("main","cart"); # # Wishlist facility # if($active_modules["Wishlist"]) { @include "../modules/Wishlist/wishlist.php"; } if ($use_intershipper == "Y") include "../shipping/intershipper.php"; else include "../shipping/myshipper.php"; #if(!$cart["shippingid"]) # $shippingid = $all_shipping [0]["shippingid"]; if ($shippingid) $cart["shippingid"]=$shippingid; # # If cart is not empty put products' details into products array # if (!func_is_cart_empty($cart)) { # # Discount coupons # if($active_modules["Discount_Coupons"]) include "../modules/Discount_Coupons/discount_coupons.php"; # # Calculate all prices # #$intershipper_recalc = "Y"; if ($intershipper_recalc == "Y") { func_calculate ($cart, $products, $login, $current_area); } if (!$cart["shippingid"]) $cart["shippingid"] = $all_shipping[0]["shippingid"]; if ($cart["shippingid"]) { $cart["shipping_special"] = array_pop(func_query_first("SELECT special FROM shipping WHERE shippingid='$cart[shippingid]'")); } else { $cart["shipping_special"] = ""; } $cart = array_merge ($cart, func_calculate($cart, $products, $login, $current_area)); $smarty->assign("cart",$cart); #echo "SS is ".sizeof($all_shipping); $smarty->assign ("shipping", $all_shipping); } # # Redirect # if($mode=="add" and $productid) { if($redirect_to_cart=="Y" || $cat=="") header("Location: cart.php"); else header("Location: home.php?cat=$cat&page=$page"); exit; } # # SHOPPING CART FEATURE # #echo "So is ".sizeof($all_shipping);exit; if (($mode=="checkout") and (!empty($cart["products"])) and (!$all_shipping) and ($login)) { header ("Location: error_message.php?error_no_shipping"); exit; } if ($mode=="checkout" && !func_is_cart_empty($cart) && ($cart["sub_total"]<$minimal_order_amount)) { header ("Location: error_message.php?error_min_order"); exit; } if($mode=="checkout" && $login=="" && !func_is_cart_empty($cart)) { # # Anonimous checkout # $smarty->assign("main","anonymous_checkout"); $smarty->assign("anonymous","Y"); } elseif($mode=="checkout" && $paymentid!="" && !func_is_cart_empty($cart)) { # # Generate uniq orderid which will identify order session # $order_secureid = md5(uniqid(rand())); # # Show payment details checkout page # $payment_data = func_query_first("select * from payment_methods where paymentid='$paymentid'"); # # Generate payment script URL depending on HTTP/HTTPS settings # $payment_data["payment_script_url"] = ($payment_data["protocol"]=="https"?$https_location:$http_location)."/payment/".$payment_data["payment_script"]."?goto=$SELLER"; $smarty->assign("payment_data",$payment_data); $smarty->assign("main","checkout"); } elseif($mode=="checkout" && !func_is_cart_empty($cart)) { # # Show checkout page with payment options only methods availiable to current # membership level are displayed # $membership = $user_account["membership"]; $p = ""; if ($SELLER) { $p = $SELLER; } else { $o = $cart["orders"]; $p = ""; if (sizeof ($o) == 1) { $p = $o[0]["provider"]; } } if ($p and $payment_methods) { foreach ($payment_methods as $k => $v) { $r = func_query_first ("SELECT * FROM seller_methods_descr WHERE login='$p' AND paymentid='$v[paymentid]'"); $payment_methods [$k]["payment_method"] = $r ["method"]; $payment_methods [$k]["payment_details"] = $r ["details"]; $payment_methods [$k]["orderby"] = $r ["orderby"]; } usort ($payment_methods, "cmp1"); } $r = func_query_first ("SELECT ckfr_login FROM customers WHERE login='$p' LIMIT 1"); $account_to_credit = $r["ckfr_login"]; $smarty->assign("payment_methods",$payment_methods); $smarty->assign("main","checkout"); $smarty->assign("checkfree_account_to_credit",$account_to_credit); } elseif ($mode=="order_message") { $smarty->assign("main","order_message"); } elseif ($mode=="auth") { $smarty->assign("main","checkout"); } require "../include/categories.php"; $giftcerts=$cart["giftcerts"]; # # In this mode cart.php show info about existing order (order_message) # if($orderids) { $orders = array (); $_orderids = split (",",$orderids); foreach ($_orderids as $orderid) { $order_data = func_order_data($orderid); # # Security check if current customer is not order's owner # if ($order_data["order"]["login"]!=$login) unset($order_data); $orders[] = $order_data; } $smarty->assign ("orders", $orders); } include "./minicart.php"; $smarty->assign("userinfo",$userinfo); $smarty->assign("products",$products); $smarty->assign("giftcerts",$giftcerts); $smarty->assign("present_card_types", $present_card_types); $smarty->assign("order",$order); $smarty->display("customer/home.tpl"); ?>