求助,商品加入购物车js提交添加
2016-07-07 15:01 来源:www.chinab4c.com 作者:ecshop专家
商品加入购物车,商品数量什么是用 js传递的,想再自己加一个传递的值,在flow.php 打印$_POST['goods'],提示例外被抛出不被接住。js代码修改如下flow.php需要改动?才能取到新加进去的值,测试n边不成功,高人帮帮忙啊 function addToCart(goodsId, parentId) { var goods= new Object(); var spec_arr= new Array(); var fittings_arr = new Array(); var number = 1; var dihuan; var formBuy= document.forms['ECS_FORMBUY']; // 检查是否有商品规格 if (formBuy) { spec_arr = getSelectedAttributes(formBuy); if (formBuy.elements['number']) { number = formBuy.elements['number'].value; } if (formBuy.elements['dihuan']) { dihuan = formBuy.elements['dihuan'].value; } } goods.spec= spec_arr; goods.goods_id = goodsId; goods.number= number; goods.dihuan= dihuan; goods.parent= (typeof(parentId) == "undefined") ? 0 : parseInt(parentId); Ajax.call('flow.php?step=add_to_cart', 'goods=' + goods.toJSONString(), addToCartResponse, 'POST', 'JSON'); } |
回答:
toJSONString()方法你看过没有? |
2# ouyoyo 需要动这个吗?现在一头雾水啊 ,,,,只需要传递过去的值能在flow.php够物车页面取到就完事了 |
我也需要啊。。 |
在线等待啊,高人帮帮忙啊 |
那有什么问题啊? |
你的意思是想把dianhua这个参数的东西也加入到购物车? Ajax.call()前加 goods.dianhua = '333333333333'; alert( goods.toJSONString()); 就能看到类似的东西, 存入购物车里的函数是 if (addto_cart($goods->goods_id, $goods->number, $goods->spec, $goods->parent)) 要是没有错的话,$goods->dianhua就是你想要的值, |
7# ouyoyo 谢谢.太感谢了,但是dihuan在商品属性页面是 <input type="radio" value= "2" name="dihuan" > <input type="radio" value="1" name="dihuan" > alert 33333可以出来 但是我要取到 name="dihuan"的直 就没有 if (formBuy.elements['dihuan']) { dihuan = formBuy.elements['dihuan'].value; } 这段有问题吗 |
如果是多选是要写一个函数把值取出来才行的,你可以参考一下 spec_arr = getSelectedAttributes(formBuy); |
我也遇到这个问题了,这是我的解决方法和问题描述: uncaught exception: [Exception... "'transport.js/parseResult() error: can't parse to JSON. <br /> <b>Warning</b>: number_format() expects parameter 1 to be double, string given in <b>D:\wamp\www\ecshop\includes\lib_common.php</b> on line <b>965</b><br /> {"error":6,"message":[{"attr_type":"1","name":"\u989c\u8272","attr_id":"185","values":[{"label":"\u9ed1\u8272","price":"","format_price":"\uffe5\u5143","id":"196"},{"label":"\u91d1\u8272","price":"10","format_price":"\uffe510.00\u5143","id":"197"},{"label":"\u767d\u8272","price":"20","format_price":"\uffe520.00\u5143","id":"198"}]}],"content":"","goods_id":"19","parent":0}' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame :: chrome://firebug/content/spy.js :: callPageHandler :: line 744" data: no] 查了下代码,在includes/lib_common.php中964行 $price = number_format($price,2, '.', '');改为下面的方式就可以工作了 $price = number_format((double)$price,2, '.', ''); |
最近更新
常用插件
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
ecshop热门问答
ecshop热门资料
ecshop开关
ecshopcookie
ecshopfavicon
ecshop给点意见
ecshop首页不显示
ecshop光纤
ecshop后进
ecshop怎样去掉这个LOGO
轮播显示
ecshop虚拟机
ecshop微信开发
ecshop律师
ecshop电子票
ecshop330
ecshopDISCUZ论坛
ecshop监控订单
ecshop违法
ecshop目标
ecshop句法
ecshop薪酬
ecshoplighttpd
ecshop比较
nginx.conf
ecshop手机中国
ecshop教训
ecshop数据库安装
美丽说模板
ecshop注册程序
ecshop淘宝店铺
ecshop安装数据错误