예제 #1
0
<?php

define('ACC', true);
require '../system/init.php';
/*
	接受goods ID
	实例化
	调用方法
	显示在view上
*/
$goods_id = $_GET['goods_id'] + 0;
$goods = new GoodsModel();
$goods123 = $goods->find($goods_id);
if (!empty($goods123)) {
    print_r($goods123);
}
예제 #2
0
파일: cart.php 프로젝트: qiushuiqs/myshop
<?php

/*
购物车控制器
*/
define('ACC', true);
require '../system/init.php';
//实例化购物车类和商品类
$cartObj = CartHelper::getCart();
$goods = new GoodsModel();
$act = isset($_GET['act']) ? $_GET['act'] : 'buy';
//购买商品,去结算
if ($act == 'buy') {
    if (isset($_GET['goods_id'])) {
        $goods_id = $_GET['goods_id'];
        $goods_info = $goods->find($goods_id);
        $num = isset($_GET['num']) ? $_GET['num'] + 0 : 1;
        //商品是否存在
        if (!isset($goods_info)) {
            $msg = "The ware is not exist<br>";
            include __ROOT__ . 'view/front/msg.html';
            exit;
        }
        //商品是否上架或者删除
        if ($goods_info['is_delete'] || !$goods_info['is_on_sale']) {
            $msg = "The ware is not available<br>";
            include __ROOT__ . 'view/front/msg.html';
            exit;
        }
        //商品是否有库存
        if ($cartObj->getNoByID($goods_id) + $num > $goods_info['goods_number']) {
예제 #3
0
@Descrition:查看商品详细信息
@Author:GongBiao
@Date:2015/06/23
*/
define('ACC', true);
require('../include/init.php');

/*
思路:
接收goods_id
实例化goodsModel
调用find方法
展示商品信息
*/
$goods_id = $_GET['goods_id'];

$goods = new GoodsModel();
$g = $goods->find($goods_id);

if(empty($g)){
	echo '商品不存在';
	exit;
}else{
	echo '<pre>';
	print_r($g); //简单的处理商品详细查看	
	echo '<pre>';
}



?>
예제 #4
0
파일: goods.php 프로젝트: qiushuiqs/myshop
<?php

/*
商品页
*/
define('ACC', true);
require '../system/init.php';
$cateObj = new CategoryModel();
$goodsObj = new GoodsModel();
$goodsID = $_GET['goods_id'];
$goodsInfo = $goodsObj->find($goodsID);
if (!isset($goodsInfo)) {
    header('Location: index.php');
}
//print_r(serialize($goodsInfo));
$catID = $goodsInfo['cat_id'];
$allCates = $cateObj->select();
$cateNav = $cateObj->getTree($allCates, $catID);
$cateInfo = $cateObj->find($catID);
//print_r($cateNav);
//加入浏览记录用cookie做
//是否有cookie,没有则设置,有则加入,超过5个自动删除
if (isset($_COOKIE['goods_history'])) {
    $history = _unserialize($_COOKIE['goods_history']);
    foreach ($history as $k => $v) {
        if ($v['goods_id'] != $goodsID) {
            continue;
        } else {
            array_splice($history, $k, 1);
            break;
        }