Exemplo n.º 1
0
<?php

session_start();
ini_set('display_errors', 0);
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
require_once "../backend/model/Frontend.php";
$model1 = new Fontend();
if (!isset($_GET['keyword'])) {
    die("");
}
$keyword = $_GET['keyword'];
//echo $keyword;die;
$data = $model1->searchForKeyword($keyword);
echo json_encode($data['data'], JSON_HEX_APOS);
Exemplo n.º 2
0
    if ($password_length > 7) {
        if ($_POST['password'] == $_POST['confirmpassword']) {
            $password = $_POST['password'];
            $style = "success";
        } else {
            $password_error = "Passwords mismatch.";
            $style = "error";
        }
    } else {
        $password_error = "Password length must be greater than 8.";
        $style = "error";
    }
}
//calling insertInto function
if ($name != "" && $email != "" && $password != "") {
    $account = new Fontend();
    $exist_account = $account->insertInto($name, $email, $password);
    echo $exist_account;
}
//remove extra white space
function test_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
Exemplo n.º 3
0
<?php

require_once "../backend/model/Frontend.php";
$model = new Fontend();
$arrMod = array("coupon");
$detailC = $model->getDetail('coupon', 1);
$mod = isset($_POST['mod']) ? $model->processData($_POST['mod']) : "";
if (in_array($mod, $arrMod)) {
    if ($mod == "coupon") {
        $arrData['name'] = $hoten = isset($_POST['snp_name']) ? $model->processData($_POST['snp_name']) : "";
        $arrData['email'] = $email = isset($_POST['snp_email']) ? $model->processData($_POST['snp_email']) : "";
        $arrData['phone'] = $dienthoai = isset($_POST['snp_dienthoai']) ? $model->processData($_POST['snp_dienthoai']) : "";
        $arrData['code'] = $detailC['code'];
        $arrData['created_at'] = time();
        $model->insert('coupon_data', $arrData);
        setcookie('snp_snppopup', 1, time() + 86400 * 30, "/");
        if ($hoten != '' && $email != '' && $dienthoai != '') {
            $tieudethu = "Vinawatch.vn :: mã giảm giá";
            $noidungthu = 'Vinawatch cảm ơn quý khách đã quan tâm tới chương trình khuyến mãi của chúng tôi.<br><br>';
            $noidungthu .= 'Vinawatch xin gửi đến quý khách mã giảm giá : ' . $detailC['code'] . '<br>';
            $model->smtpmailer($email, '*****@*****.**', 'vinawatch.vn', $tieudethu, $noidungthu);
            echo "success";
        }
    }
} else {
    echo "Stop here!";
    exit;
}
Exemplo n.º 4
0
function checkCat($uri)
{
    require_once 'backend/model/Frontend.php';
    $model = new Fontend();
    $uri = str_replace("+", "", $uri);
    $p_detail = '#details/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_detail_news = '#tin-tuc/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_cate_news = '#danh-muc/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_detail_event = '#su-kien/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_tag = '#/tag/[a-z\\-]+.html#';
    $p_contact = '#/lien-he+.html#';
    $p_order = '#/quan-ly-don-hang+.html#';
    $p_orderdetail = '#/chi-tiet-don-hang+.html#';
    $p_info = '#/cap-nhat-thong-tin+.html#';
    $p_changepass = '******';
    $p_logout = '#/thoat+.html#';
    $p_hot = '#/san-pham-noi-bat+.html#';
    $p_sale = '#/san-pham-giam-gia+.html#';
    $p_cart = '#/gio-hang+.html#';
    $p_register = '#/dang-ky+.html#';
    $p_about = '#/gioi-thieu+.html#';
    $p_thanhtoan = '#/thanh-toan+.html#';
    $p_tintuc = '#/tin-tuc+.html#';
    $p_cate = '#/[a-z0-9\\-]+\\-+p+\\d+c+\\d+.html#';
    $p_content = '#/[a-z0-9\\-]+\\-+c+\\d+.html#';
    $p_search = '#/tim-kiem+.html#';
    $mod = "";
    $page_id = "";
    if (preg_match($p_register, $uri)) {
        $mod = "register";
        if (!empty($_SESSION['user'])) {
            header('location:gio-hang.html');
        }
    }
    if (preg_match($p_cart, $uri)) {
        $mod = "cart";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    }
    if (preg_match($p_search, $uri)) {
        $mod = "search";
    }
    if (preg_match($p_order, $uri)) {
        $mod = "order";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    }
    if (preg_match($p_info, $uri)) {
        $mod = "info";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    }
    if (preg_match($p_changepass, $uri)) {
        $mod = "changepass";
        $seo = $model->getDetailSeo(9);
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    }
    if (preg_match($p_about, $uri)) {
        $mod = "about";
        $seo = $model->getDetailSeo(2);
    }
    if (preg_match($p_thanhtoan, $uri)) {
        $mod = "thanhtoan";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    }
    if (preg_match($p_detail, $uri)) {
        $mod = "detail";
    }
    if (preg_match($p_detail_news, $uri)) {
        $mod = "detail-news";
    }
    if (preg_match($p_detail_event, $uri)) {
        $mod = "detail-event";
    }
    if (preg_match($p_tintuc, $uri)) {
        $mod = "news";
        $seo = $model->getDetailSeo(4);
    }
    if (preg_match($p_cate_news, $uri)) {
        $mod = "cate-news";
    }
    if (preg_match($p_cate, $uri)) {
        $mod = "cate";
    }
    if (preg_match($p_content, $uri)) {
        $mod = "content";
    }
    if (preg_match($p_hot, $uri)) {
        $mod = "hot";
    }
    if (preg_match($p_sale, $uri)) {
        $mod = "sale";
    }
    if (preg_match($p_contact, $uri)) {
        $mod = "contact";
    }
    if (preg_match($p_orderdetail, $uri)) {
        $mod = "orderdetail";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    }
    if (preg_match($p_logout, $uri)) {
        session_destroy();
        $mod = "";
        $seo = $model->getDetailSeo(1);
    }
    return array("seo" => $seo, "mod" => $mod, 'page_id' => $page_id);
}
Exemplo n.º 5
0
<?php

session_start();
ini_set('display_errors', 0);
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
date_default_timezone_set('Asia/Saigon');
require_once 'routes.php';
require_once "backend/model/Frontend.php";
$model = new Fontend();
$detailCoupon = $model->getDetail('coupon', 1);
$start_date_coupon = $detailCoupon['start_date'];
$end_date_coupon = $detailCoupon['end_date'];
$status_coupon = $detailCoupon['status'];
if ($status_coupon && strtotime($start_date_coupon) <= time() && strtotime($end_date_coupon) >= time() && !$_COOKIE['snp_snppopup']) {
    $haveCoupon = 1;
} else {
    $haveCoupon = 0;
}
?>
<!doctype html>
<html lang="vi">
	<head>		
		<title><?php 
echo $seo['meta_title'];
?>
</title>				
		<base href="http://<?php 
echo $_SERVER['SERVER_NAME'];
?>
">		
		<meta charset="utf-8">
Exemplo n.º 6
0
<?php

session_start();
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$arrParam['name'] = $model->processData($_POST['full_name']);
$arrParam['mobile'] = $model->processData($_POST['phone']);
$arrParam['email'] = $model->processData($_POST['email']);
$arrParam['title'] = $model->processData($_POST['title']);
$arrParam['content'] = $model->processData($_POST['content']);
$arrParam['status'] = 1;
$arrParam['type'] = 3;
$arrParam['creation_time'] = time();
$arrParam['update_time'] = time();
$column = $values = "";
foreach ($arrParam as $key => $value) {
    $column .= "{$key}" . ",";
    $values .= "'" . $value . "'" . ",";
}
$column = rtrim($column, ",");
$values = rtrim($values, ",");
$sql = "INSERT INTO sendcontent(" . $column . ") VALUES (" . $values . ")";
mysql_query($sql) or die(mysql_error());
$id = mysql_insert_id();
if ($id > 0) {
    echo "success";
} else {
    echo "error";
}
Exemplo n.º 7
0
<?php

include 'functions/toUppercase_function.php';
include 'fontendClass/fontend.php';
$fontend_object = new Fontend();
$user_id = (int) $_REQUEST['id'];
?>
<html>
<head>
    <link rel="stylesheet" href="bootstrap.min.css">
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            var maxLength = 200;
            $(".show-read-more").each(function(){
                var myStr = $(this).text();
                if($.trim(myStr).length > maxLength){
                    var newStr = myStr.substring(0, maxLength);
                    var removedStr = myStr.substring(maxLength, $.trim(myStr).length);
                    $(this).empty().html(newStr);
                    $(this).append(' <a href="javascript:void(0);" class="read-more">read more...</a>');
                    $(this).append('<span class="more-text">' + removedStr + '</span>');
                }
            });
            $(".read-more").click(function(){
                $(this).siblings(".more-text").contents().unwrap();
                $(this).remove();

            });
        });
    </script>
Exemplo n.º 8
0
<?php

session_start();
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$action = $_POST['action'];
$code = $_POST['code'];
$arr = array();
$detail = $model->getDetailCode($code);
if (!empty($detail)) {
    if ($detail['type'] == 1) {
        $v = str_replace("%", "", $detail['code_value']);
    }
    if ($detail['type'] == 2) {
        $v = $detail['code_value'];
    }
    if (!empty($_SESSION['cart'])) {
        foreach ($_SESSION['cart'] as $value) {
            $tongtien += $value['tientheosp'];
        }
    }
    if ($detail['type'] == 1) {
        $pay = $tongtien * (100 - $v) / 100;
        $coupon = $tongtien * $v / 100;
    }
    if ($detail['type'] == 2) {
        $pay = $tongtien - $v;
        $coupon = $v;
    }
    $arr['mess'] = 'success';
    $arr['pay'] = $pay;
Exemplo n.º 9
0
<?php

session_start();
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$arrParam = $_POST;
$total_price = $total_amount = $total_pay = $customer_id = $code_id = $discount = 0;
/*$seed = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                 .'0123456789'); // and any other characters
shuffle($seed); // probably optional since array_is randomized; this may be redundant
$rand = '';
foreach (array_rand($seed, 5) as $k) $rand .= $seed[$k];
*/
$order_code = "DH-" . date('Ym');
$idMax = $model->getOrderIdMax();
$order_code = "DH-" . date('Ym') . '-' . $idMax;
$arrParam['order_code'] = $order_code;
$arrParam['status'] = 1;
$arrParam['created_at'] = time();
$arrParam['delivery_date'] = strtotime($_POST['delivery_date']);
$back_url = $_POST['back_url'];
if (!empty($_SESSION['cart'])) {
    foreach ($_SESSION['cart'] as $product) {
        $total_price += $product['tientheosp'];
        $total_amount += $product['soluong'];
    }
}
$arrParam['sub_total'] = $total_price;
if (isset($_SESSION['pay'])) {
    $arrParam['total'] = $_SESSION['pay'];
} else {
Exemplo n.º 10
0
<?php

ini_set('display_errors', 0);
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$product_id = (int) $_POST['product_id'];
$detail = $model->getDetailProduct($product_id);
$product = $detail['data'];
?>
<div class="col-md-5" style="padding:10px;background-color:#F5D927;height:400px">
	<h1><?php 
echo $product['product_name'];
?>
</h1>
	<div class="col-md-6">Giá thị trường</div>
	<div class="col-md-6">
		<h3 class="price-old" style="color:#FFF;text-decoration:line-through">
			<?php 
echo number_format($product['price'], 0, ",", ".");
?>
 đ
		</h3>
	</div>
	<div class="col-md-6">Giá giờ vàng</div>
	<div class="col-md-6">
		<h3 class="price-sale" style="color:#ac0e0f">
			<?php 
echo number_format($product['price_saleoff'], 0, ",", ".");
?>
 đ
		</h3>
Exemplo n.º 11
0
<?php

require_once "../backend/model/Frontend.php";
$model = new Fontend();
$cate_id = isset($_POST['cate_id']) ? $_POST['cate_id'] : -1;
$parent_id = isset($_POST['parent_id']) ? $_POST['parent_id'] : '';
$giatu = isset($_POST['giatu']) ? $_POST['giatu'] : '';
$giaden = isset($_POST['giaden']) ? $_POST['giaden'] : '';
$age_range = isset($_POST['age_range']) ? $_POST['age_range'] : '';
$hot = isset($_POST['hot']) ? $_POST['hot'] : '';
$is_new = isset($_POST['is_new']) ? $_POST['is_new'] : '';
$is_saleoff = isset($_POST['is_saleoff']) ? $_POST['is_saleoff'] : '';
$keyword = isset($_POST['keyword']) ? $_POST['keyword'] : '';
$catetype = isset($_POST['catetype']) ? $_POST['catetype'] : '';
$page = isset($_POST['page_search']) ? (int) $_POST['page_search'] : 1;
//$cate_id = $_POST['cate_id'];
$cate_id = $cate_id == 0 ? -1 : $cate_id;
$page_show = 5;
if ($catetype != '') {
    $arrTotal = $model->getListProductCateTypeSearch($catetype, $giatu, $giaden, -1, -1);
} else {
    $arrTotal = $model->getListProductCate($keyword, $parent_id, $cate_id, $giatu, $giaden, $age_range, $hot, $is_saleoff, $is_new, -1, -1);
}
$limit = 20;
$total_page = ceil($arrTotal['total'] / $limit);
$offset = $limit * ($page - 1);
if ($catetype != '') {
    $arrList = $model->getListProductCateTypeSearch($catetype, $giatu, $giaden, $offset, $limit);
} else {
    $arrList = $model->getListProductCate($keyword, $parent_id, $cate_id, $giatu, $giaden, $age_range, $hot, $is_saleoff, $is_new, $offset, $limit);
}
<?php

include 'fontendClass/fontend.php';
$fontend_object = new Fontend();
$category_id = (int) $_REQUEST['id'];
?>
<html>
<head>
    <link rel="stylesheet" href="bootstrap.min.css">
    <!--for read more option-->
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            var maxLength = 200;
            $(".show-read-more").each(function(){
                var myStr = $(this).text();
                if($.trim(myStr).length > maxLength){
                    var newStr = myStr.substring(0, maxLength);
                    var removedStr = myStr.substring(maxLength, $.trim(myStr).length);
                    $(this).empty().html(newStr);
                    $(this).append(' <a href="javascript:void(0);" class="read-more">read more...</a>');
                    $(this).append('<span class="more-text">' + removedStr + '</span>');
                }
            });
            $(".read-more").click(function(){
                $(this).siblings(".more-text").contents().unwrap();
                $(this).remove();

            });
        });
    </script>
Exemplo n.º 13
0
function checkCat($uri)
{
    require_once 'backend/model/Frontend.php';
    $model = new Fontend();
    $uri = str_replace("+", "", $uri);
    $p_detail = '#chi-tiet/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_detail_news = '#tin-tuc/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_cate_page = '#/[a-z0-9\\-\\+]+.html#';
    $p_product_detail = '#[a-z0-9\\-\\+]/[a-z0-9\\-\\+]/[a-z0-9\\-\\+]+.html#';
    $p_cate_news = '#danh-muc/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_detail_event = '#su-kien/[a-z0-9\\-\\+]+\\-\\d+.html#';
    $p_tag = '#/tag/[a-z\\-]+.html#';
    $p_contact = '#/lien-he+.html#';
    $p_order = '#/quan-ly-don-hang+.html#';
    $p_orderdetail = '#/chi-tiet-don-hang+.html#';
    $p_info = '#/cap-nhat-thong-tin+.html#';
    $p_changepass = '******';
    $p_logout = '#/thoat+.html#';
    $p_hot = '#/[a-z0-9\\-]+\\-+c+\\d+h+\\d+.html#';
    $p_sale = '#/[a-z0-9\\-]+\\-+c+\\d+s+\\d+.html#';
    $p_cart = '#/gio-hang+.html#';
    $p_register = '#/dang-ky+.html#';
    $p_about = '#/gioi-thieu+.html#';
    $p_thanhtoan = '#/thanh-toan+.html#';
    $p_tintuc = '#/tin-tuc+.html#';
    $p_cate = '#/[a-z0-9\\-]+\\-+p+\\d+.html#';
    $p_content = '#/[a-z0-9\\-]+\\-+c+\\d+.html#';
    $p_search = '#/tim-kiem+.html#';
    $mod = $seo = "";
    $object_id = 0;
    $arrTmp = explode('/', $uri);
    if (count($arrTmp) == 4) {
        $mod = "detail";
    } elseif (strpos($uri, 'tin-tuc/')) {
        $mod = "detail-news";
    } elseif (strpos($uri, 'tim-kiem.')) {
        $mod = "search";
    } elseif (strpos($uri, 'dat-hang-thanh-cong.')) {
        $mod = "thanks";
    } elseif (strpos($uri, 'danh-muc/')) {
        $mod = "cate-news";
    } elseif (strpos($uri, 'dang-ky')) {
        $mod = "register";
        if (!empty($_SESSION['user'])) {
            $rel = isset($_GET['rel']) ? $_GET['rel'] : 'gio-hang';
            header('location:' . $rel . '.html');
        }
    } elseif (strpos($uri, 'cap-nhat-thong-tin')) {
        $mod = "info";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    } elseif (strpos($uri, 'quan-ly-don-hang')) {
        $mod = "order";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    } elseif (strpos($uri, 'chi-tiet-don-hang')) {
        $mod = "orderdetail";
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    } elseif (strpos($uri, 'doi-mat-khau')) {
        $mod = "changepass";
        $seo = $model->getDetailSeo(9);
        if (empty($_SESSION['user'])) {
            header('location:dang-ky.html');
        }
    } else {
        if (preg_match($p_product_detail, $uri)) {
            $mod = "product_detail";
        }
        if (preg_match($p_cart, $uri)) {
            $mod = "cart";
            if (empty($_SESSION['user'])) {
                //    header('location:dang-ky.html');
            }
        }
        if (preg_match($p_search, $uri)) {
            $mod = "search";
        }
        if (preg_match($p_cate_page, $uri)) {
            $uri = substr($uri, 1);
            $tmp = explode(".", $uri);
            if ($tmp[0] == "lien-he") {
                $mod = "contact";
            } elseif ($tmp[0] == "thanh-toan") {
                $mod = "thanhtoan";
            } elseif ($tmp[0] == "tin-tuc") {
                $mod = "news";
                $seo = $model->getDetailSeo(4);
            } else {
                $row = $model->getDetailAlias($tmp[0]);
                if ($row['type'] == 1) {
                    $mod = 'cate';
                } elseif ($row['type'] == 2) {
                    $mod = 'content';
                } elseif ($row['type'] == 3) {
                    $mod = 'catetype';
                }
                //$mod = $row['type'] == 1 ? "cate" : "content";
                $object_id = $row['object_id'];
            }
        }
        if (preg_match($p_about, $uri)) {
            $mod = "about";
            $seo = $model->getDetailSeo(2);
        }
        if (preg_match($p_thanhtoan, $uri)) {
            $mod = "thanhtoan";
            if (empty($_SESSION['user'])) {
                //    header('location:dang-ky.html');
            }
        }
        if (preg_match($p_detail_news, $uri)) {
            $mod = "detail-news";
        }
        if (preg_match($p_detail_event, $uri)) {
            $mod = "detail-event";
        }
        if (preg_match($p_tintuc, $uri)) {
            $mod = "news";
            $seo = $model->getDetailSeo(4);
        }
        if (preg_match($p_cate_news, $uri)) {
            $mod = "cate-news";
        }
        if (preg_match($p_cate, $uri)) {
            $mod = "cate";
        }
        if (preg_match($p_content, $uri)) {
            $mod = "content";
        }
        if (preg_match($p_hot, $uri) || preg_match($p_sale, $uri)) {
            $mod = "catetype";
        }
        if (preg_match($p_contact, $uri)) {
            $mod = "contact";
        }
        if (preg_match($p_logout, $uri)) {
            session_destroy();
            $mod = "";
            $seo = $model->getDetailSeo(1);
        }
    }
    return array("seo" => $seo, "mod" => $mod, 'object_id' => $object_id);
}
Exemplo n.º 14
0
<?php

session_start();
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$action = $_POST['action'];
if ($action == 'register') {
    $arrReturn = array();
    $username = $_POST['username'];
    $password = $_POST['password'];
    $password2 = $_POST['password2'];
    $email = $_POST['email'];
    $full_name = $_POST['full_name'];
    $address = $_POST['address'];
    $city = (int) $_POST['city'];
    $phone = $_POST['phone'];
    $handphone = $_POST['handphone'];
    if ($username != '' && $password != '' && $password == $password2 && $email != '' && $full_name != '' && $address != '' && $city > 0) {
        if ($model->checkUsernameExist($username) == "0") {
            echo "Tên đăng nhập đã được sử dụng.";
            exit;
        }
        if ($model->checkEmailUsed($email) == "0") {
            echo "Email đã được sử dụng.";
            exit;
        }
        $password = md5($password);
        $user_id = $model->insertUser($username, $password, $email, $full_name, $address, $city, $phone, $handphone);
        echo "Đăng ký thành viên thành công.";
        $_SESSION['user'] = $model->getDetailUser($user_id);
        exit;
Exemplo n.º 15
0
<?php

require_once "../backend/model/Frontend.php";
$model = new Fontend();
$city_id = (int) $_POST['city_id'];
$stateArr = $model->getListStateByCity($city_id);
if (!empty($stateArr)) {
    foreach ($stateArr as $value) {
        echo "<option value='" . $value['id'] . "'>" . $value['state_name'] . "</option>";
    }
}
Exemplo n.º 16
0
<?php

include 'fontendClass/fontend.php';
include 'functions/toUppercase_function.php';
$fontend_object = new Fontend();
$email = "";
$password = "";
//check email validation
if (isset($_POST["email"]) && $_POST["email"] != "") {
    $email = mysqli_real_escape_string($fontend_object->conn, $_POST['email']);
}
//check password validation
if (isset($_POST["password"]) && $_POST["password"] != "") {
    $password = mysqli_real_escape_string($fontend_object->conn, $_POST['password']);
}
//call checkLogin function for user check
if ($email != "" && $password != "") {
    if ($fontend_object->checkLogin($email, $password)) {
        Header("Location: postpage.php");
    } else {
        echo "<script>alert('Email or Password mismatch.')</script>";
    }
}
?>
<html>
<head>
    <link rel="stylesheet" href="bootstrap.min.css">
    <!--for read more option-->
    <!--<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>-->
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
Exemplo n.º 17
0
<?php

session_start();
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$action = $_POST['action'];
$product_id = (int) $_POST['product_id'];
//var_dump($product_id);
$arrDetailProduct = $model->getDetailProduct($product_id);
$data = $arrDetailProduct['data'];
//var_dump("<pre>",$data);
if (!isset($_SESSION['cart_id'])) {
    $_SESSION['cart_id'] = array();
}
if ($product_id > 0) {
    if ($action == 'add') {
        if (!in_array($product_id, $_SESSION['cart_id'])) {
            $_SESSION['cart_id'][] = $product_id;
            $_SESSION['cart'][$product_id]['id'] = $product_id;
            $_SESSION['cart'][$product_id]['soluong'] = 1;
            $_SESSION['cart'][$product_id]['giatien'] = $data['price_saleoff'] > 0 ? $data['price_saleoff'] : $data['price'];
            $_SESSION['cart'][$product_id]['image_url'] = $data['image_url'];
            $_SESSION['cart'][$product_id]['product_name'] = $data['product_name'];
            $_SESSION['cart'][$product_id]['tientheosp'] = $data['price_saleoff'] > 0 ? $data['price_saleoff'] : $data['price'];
            var_dump("<pre>", $_SESSION['cart'][$product_id]);
            die;
        } else {
            $_SESSION['cart'][$product_id]['soluong']++;
            $_SESSION['cart'][$product_id]['tientheosp'] = $_SESSION['cart'][$product_id]['soluong'] * $_SESSION['cart'][$product_id]['giatien'];
        }
    }
Exemplo n.º 18
0
<?php

//ini_set('display_errors', 1);
//phpinfo();
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$product_id = (int) $_POST['product_id'];
$detail = $model->getDetailProduct($product_id);
$data = $detail['data'];
$type = (int) $_POST['type'];
//1 : giao hang , 2 : giu hang , 3 : dat truoc
?>
<div class="wrap_cart" id="wrap_cart">
    <form id="orderForm" action="ajax/payment.php" method="post">
        <div class="col-md-12">
            <div class="col-md-5">
                <p style="text-align:center">
                    <img src="<?php 
echo $data['image_url'];
?>
" width="120" />
                </p>
                <h3 class="clearfix" style="margin-top:5px"><?php 
echo $data['product_name'];
?>
</h3>
                <h2 class="product_price">
                  <?php 
if ($data['price_saleoff'] > 0) {
    echo number_format($data['price_saleoff'], 0, ",", ".");
} else {