服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > ecshop教程 >

为ecshop用户提供商品批备注功能(3)

时间:2014-12-25 00:19来源:未知 作者:最模板 点击:
【18】index.php中注释掉: $ua = strtolower($_SERVER[HTTP_USER_AGENT]); $uachar = /(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i; if(($ua == || pre


【18】index.php中注释掉:
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);


$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";


if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))
{
    $Loaction = 'mobile/';


    if (!empty($Loaction))
    {
        ecs_header("Location: $Loaction\n");


        exit;
    }


}


【19】goods.php中增加函数:
/*------------------------------------------------------ */
//-- 修改商品批注
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'edit_goods_comment')
{
    include('includes/cls_json.php');
    $json   = new JSON;
    $res    = array('err_msg' => '', 'result' => '');

    $goods_id   = intval($_POST['id']);
    $_POST['val'] = json_str_iconv($_POST['val']);
    $goods_comment = $json->decode($_POST['val']);


    $sql = "DELETE FROM goods_comment WHERE goods_id = '". $goods_id. "' AND user_id = '". $_SESSION["user_id"] ."'";
    $GLOBALS['db']->query($sql);
    $sql = "INSERT INTO goods_comment (goods_id, user_id, goods_comment) VALUES ('". $goods_id."', '".$_SESSION["user_id"]."', '".$goods_comment."')";
    $GLOBALS['db']->query($sql);

    $res['result'] = $goods_comment;

    die($json->encode($res));
}


【20】flow.php文件中:
在:
/* 插入订单商品 */
    $sql = "INSERT INTO " . $ecs->table('order_goods') . "( " .
                "order_id, goods_id, goods_name, goods_sn, product_id, goods_number, market_price, ".
                "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id) ".
            " SELECT '$new_order_id', goods_id, goods_name, goods_sn, product_id, goods_number, market_price, ".
                "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id".
            " FROM " .$ecs->table('cart') .
            " WHERE session_id = '".SESS_ID."' AND rec_type = '$flow_type'";
    $db->query($sql);
后边增加:
/* 插入订单商品批注 */
    $sql = "INSERT INTO order_comment (order_id, goods_id, goods_comment) ".
      "(SELECT '$new_order_id', cart.goods_id, gc.goods_comment ".
    "FROM cart LEFT JOIN goods_comment as gc ON gc.goods_id = cart.goods_id AND gc.user_id = cart.user_id)";
    $db->query($sql);


【21】category.php文件中:
/* 获得商品列表 */
    $sql = 'SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_weight, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
                "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
                'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' .
            'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
            'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
                "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
            "WHERE $where $ext ORDER BY $sort $order";
改为:
/* 获得商品列表 */
    $sql = 'SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_weight, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
                "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
                'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img, gc.goods_comment ' .
            'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
            'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
                "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
                "LEFT JOIN goods_comment as gc ON gc.goods_id = g.goods_id AND gc.user_id = '" . $_SESSION[user_id] . "' ".
            "WHERE $where $ext ORDER BY $sort $order";


在:
$arr[$row['goods_id']]['name']             = $row['goods_name'];
        $arr[$row['goods_id']]['goods_brief']      = $row['goods_brief'];
        $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
        $arr[$row['goods_id']]['market_price']     = price_format($row['market_price']);
        $arr[$row['goods_id']]['shop_price']       = price_format($row['shop_price']);
        $arr[$row['goods_id']]['type']             = $row['goods_type'];
        $arr[$row['goods_id']]['promote_price']    = ($promote_price > 0) ? price_format($promote_price) : '';
        $arr[$row['goods_id']]['goods_thumb']      = get_image_path($row['goods_id'], $row['goods_thumb'], true);
        $arr[$row['goods_id']]['goods_img']        = get_image_path($row['goods_id'], $row['goods_img']);
        $arr[$row['goods_id']]['url']              = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
        $arr[$row['goods_id']]['goods_sn']         = $row['goods_sn'];
        $arr[$row['goods_id']]['goods_weight']     = $row['goods_weight'];
后边增加:
/* 获取批注 */
        $arr[$row['goods_id']]['goods_comment']    = $row['goods_comment'];(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(1)
100%
------分隔线----------------------------
栏目列表
热点内容