通过AJAX方式动态更新ecshop购物车页面的商品数量
}
$GLOBALS['db']->query($sql);
include_once(‘includes/cls_json.php’);
每次用户进入ecshop购物流程的时候当需要更改购物车里的商品数量的时候必须要手动点击更新按钮,这是非常糟糕的用户体验,我们有必要去改进这一点。
二、在flow.php文件中插入对应的处理代码:
$result['rec_id'] = $rec_id;
<INPUT onblur=”changePrice(document.getElementById(‘goods_number_{$goods.rec_id}’).value,{$goods.rec_id})” name=”goods_number[{$goods.rec_id}]” id=”goods_number_{$goods.rec_id}” value=”{$goods.goods_number}” id=”ECS_FORMBUY”>
Ajax.call(‘flow.php’, ‘step=update_group_cart&rec_id=’ + rec_id +’&number=’ + number, changePriceResponse, ‘GET’, ‘JSON’);
document.getElementById(‘subtotal_’+res.rec_id).innerHTML = res.subtotal;
if(!is_numeric($number))
}
一、前端页面部分(flow.dwt)
$result = array(‘error’ => ”, ‘content’ => ”);
</script>
if (res.error > 0)
die($json->encode($result));
die($json->encode($result));
}
在商品数量的input框添加对应的js函数
$result['subtotal'] = price_format($subtotal, false);
{
$restrict_amount = $group_buy['restrict_amount'] – $group_buy['valid_goods'];
还等什么?马上清空echsop的缓存刷新页面看看效果吧。
$cart_amount = cart_amount(”,$_SESSION['flow_type']);
document.all.sysmsg_error.style.display=’none’;
elseif($_REQUEST['step'] == ‘update_group_cart’)
function changePrice(number,rec_id)
{
$number = $_GET['number'];
{
$sql = “UPDATE ” . $GLOBALS['ecs']->table(‘cart’) . ” SET goods_number = ‘$number’ WHERE rec_id = $rec_id”;
document.getElementById(‘sysmsg_error’).innerHTML = res.content;
{
$result['content'] =’请输入合法数量’;
$result['error'] = ’1′;
{
die($json->encode($result));
function changePriceResponse(res)
{
if(document.all.sysmsg_error.style.display==”)
}
var qty = document.forms['ECS_FORMBUY'].elements['number'].value;
{
以下是通过AJAX方式来动态更新ECShop购物车页面商品数量的解决办法
var attr = getSelectedAttributes(document.forms['ECS_FORMBUY']);
$group_buy = group_buy_info($_SESSION['extension_id'], $number);
<script type=”text/javascript”>
在文件最后添加一段js
$subtotal = $GLOBALS['db']->getONE(“select goods_price * goods_number AS subtotal from “.$GLOBALS['ecs']->table(‘cart’).” where rec_id = $rec_id”);
$json = new JSON();
document.getElementById(‘cart_amount’).innerHTML = res.cart_amount;
$rec_id = $_GET['rec_id'];
$result['cart_amount'] = price_format($cart_amount, false);
document.all.sysmsg_error.style.display=”;
}
}
$result['error'] = ’1′;
}
else
if ($group_buy['restrict_amount'] > 0 && $number > ($group_buy['restrict_amount'] – $group_buy['valid_goods']))
}
{
$result['content'] =’您最多可买’.$restrict_amount.’件’;
相关热词: ecshop
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jz/ecshop/3654.shtml
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
ecshop中设置顺丰快递支持
时间:2020-12-28
-
ecshop图文安装过程详解
时间:2020-12-28
-
ecshop邮件服务器设置方法
时间:2020-12-23
热门文章
-
ecshop中设置顺丰快递支持货到付款的方法
时间:2020-12-28
-
ecshop邮件服务器设置方法
时间:2020-12-23
-
ecshop图文安装过程详解
时间:2020-12-28
