ecshop ajax报错,给ecshop增加ajax购物车列表(jQuery版)

购物车

绑定onmouseover onmouseout(function ($){

$('#i_cart_info').hover(

function(){

$('.cart_list').css({'display':''});

$.post("/api/cart_list.php", function(data){

$('.cart_list').html(data);

});

},

function(){

$('.cart_list').css({'display':'none'});

$('.cart_list').html('');

}

);

})(jQuery);

效果图

fcb45ae0144d50517e7f74359e0eb63d.png.cart_bd .cart_list {

z-index:901;

position:absolute;

/*top:30px;*/

right:0;

width:251px;

border:2px #FFBA00 solid;

background-color:#fff

}

.cart_bd .cart_list .empty {

padding:3px 8px

}

.cart_bd .cart_list li {

height:70px;

border-bottom:1px #E1E1E1 solid;

float:left;

}

.cart_bd .cart_list .pic_wrap {

float:left;

overflow:hidden;

width:50px;

height:50px;

padding:10px;

line-height:50px

}

.cart_bd .cart_list .pic_wrap img {

width:50px;

border:1px solid #dedede;

}

.cart_bd .cart_list .txt_wrap {

position:relative;

overflow:hidden;

#zoom:1;

padding:6px 10px 0 0

}

.cart_bd .cart_list .name {

overflow:hidden;

/*height:39px;*/

text-align:left;

}

.cart_bd .cart_list .name a {

overflow:hidden;

display:block;

float:left;

height:36px;

line-height:18px

}

.cart_bd .cart_list .action {

text-align:left;

color:#f00000

}

.cart_bd .cart_list .remove {

float:right;

margin-top:2px

}

.cart_bd .cart_list .rmb {

margin-right:3px;

font-family:Arial;

color:#f00000

}

.cart_bd .cart_list .price {

margin-right:5px;

font-size:14px;

color:#f00000

}

.cart_bd .cart_list .ride {

color:#666

}

.cart_bd .cart_list dl {

padding:7px 10px 15px;

text-align:right;

clear:both;

}

.cart_bd .cart_list dt {

height:21px

}

.cart_bd .cart_list dt .rmb {

margin-left:3px

}

.cart_bd .cart_list .fee_tip {

margin-bottom:9px;

color:#999

}

.cart_bd .cart_list .balance:link,.cart_bd .cart_list .balance:visited,

.cart_bd .cart_list .balance:hover,.cart_bd .cart_list .balance:active {

display:inline-block;

width:114px;

height:30px;

background-color:#FF624D;

text-align:center;

line-height:30px;

font-size:14px;

color:#fff;

text-decoration:none

}

  • {$goods.goods_name}

    ¥{$goods.goods_price}

    x{$goods.goods_number}

共{$total_number}件商品

总计:¥{$subtotal}

去购物车结算

共0件商品

您的购物车是空的快挑选喜欢的商品加入购物车吧

phpdefine('IN_ECS', true);

require('./init.php');

require('../includes/lib_order.php');

if(!defined('SESS_ID')) {

define('SESS_ID',$sess->get_session_id());

}

if (!defined('INIT_NO_SMARTY'))

{

header('Cache-control: private');

header('Content-type: text/html; charset='.EC_CHARSET);

/* 创建 Smarty 对象。*/

require('../includes/lib_main.php');

require('../includes/cls_template.php');

$smarty = new cls_template;

$smarty->cache_lifetime = $_CFG['cache_time'];

$smarty->template_dir   = ROOT_PATH . 'themes/' . $_CFG['template'];

$smarty->cache_dir      = ROOT_PATH . 'temp/caches';

$smarty->compile_dir    = ROOT_PATH . 'temp/compiled';

if ((DEBUG_MODE & 2) == 2)

{

$smarty->direct_output = true;

$smarty->force_compile = true;

}

else

{

$smarty->direct_output = false;

$smarty->force_compile = false;

}

$smarty->assign('lang', $_LANG);

$smarty->assign('ecs_charset', EC_CHARSET);

if (!empty($_CFG['stylename']))

{

$smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style_' . $_CFG['stylename'] . '.css');

}

else

{

$smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style.css');

}

}

//判断是否ajax提交

if($_SERVER[ 'HTTP_X_REQUESTED_WITH' ] !== 'XMLHttpRequest') {

exit();

}

/* 取得购物类型 */

$flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;

/* 对商品信息赋值 */

$cart_goods = cart_goods($flow_type); // 取得商品列表,计算合计

//根据商品ID 去查找缩略图

if(!is_array($cart_goods) || count($cart_goods) 

//echo "您的购物车是空的
快挑选喜欢的商品加入购物车吧";

$smarty->display('cart_list.dwt');

exit;

}

$tmp_cart_goods = $goods_ids = array();

$total_number = $subtotal = 0;

foreach($cart_goods as $key=>$val) {

$tmp_cart_goods[$val['goods_id']] = $val;

$goods_ids[] = $val['goods_id'];

$total_number += $val['goods_number'];

$subtotal += $val['subtotal'];

}

$goods_str = implode(',',$goods_ids);

$result = $db->query("SELECT goods_id,goods_thumb FROM ".$ecs->table('goods')." WHERE goods_id IN($goods_str)");

while($row = $db->fetch_array($result)) {

$tmp_cart_goods[$row['goods_id']]['goods_thumb'] = $row['goods_thumb'];

}

$cart_goods = & $tmp_cart_goods;

$smarty->assign('total_number',$total_number);

$smarty->assign('subtotal',$subtotal);

$smarty->assign('cart_goods',$cart_goods);

$smarty->display('cart_list.dwt');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值