怎么样给ECShop购物车添加购买数量加减按钮

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:18   1463   0

怎么样给ECShop购物车添加购买数量加减按钮




添加以下代码到 /js/common.js 下1:


/**
* 购物车加减按钮
* @param txt_id 数量的ID
* @param type 加 + 减 -
* @param num 添加或者减少的数量 默认为一
*/
function cart_number(txt_id, type, num)
{
num = num || 1;
var txt = document.getElementById(txt_id);
var source_num = parseInt(txt.value);
if (source_num == 1 && type == '-' )
{
alert( '请最少购买一个商品' );
return ;
}
var to_num = source_num;
if (type == '+' )
{
to_num += num;
}
elseif (type == '-' )
{
to_num -= num;
}
txt.value = to_num;
showdiv(txt);
}

2. flow.dwt页面 搜索 goods_number 的input, 在input 两侧两天,如果想使用图片替换加号和减号:

<a href="javascript:cart_number('goods_number_{$goods.rec_id}', '-');;">-</a><a href="javascript:cart_number('goods_number_{$goods.rec_id}', '+');;">+</a>

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP