51可用代码模板网站

咨询热线:

181-1164-6936
  • 1
ECSHOP商城
当前位置:首页>实用代码>ECSHOP商城>

ecshop开发之如何实现团购网的倒计时功能

时间:2017-08-10 16:11点击:
先,你需要在购买的时候,提示输入框,告诉用户,你必须购买多少.其次,购物车中需要修改购买数量的时候,你也需要控制。
   1:详细页面中控制.

   在flow.PHP里面addto_cart中,加入以下代码,控制购买.


 $gc = $db -> getOne("select gc from ".$ecs->table('goods')." where goods_id = ".$goods ->goods_id);
       if ($goods->number%$gc) {
      $result['error'] = 1;
      $result['message'] = "购买数量必须输入{$gc}的倍数";
       }
2:在common.js中增加函数



 function addToCart1(goodsId, parentId)
{
   var goods        = new Object();
   var spec_arr     = new Array();
   var fittings_arr = new Array();
   var number    = 1;
   var t = "number"+goodsId;
   number = document.getElementByIdx_x("number"+goodsId).value;
   goods.spec     = spec_arr;
   goods.goods_id = goodsId;
   goods.number = number;
   goods.parent = (typeof(parentId) == "undefined") ? 0 : parseInt(parentId);
   Ajax.call('flow.php?step=add_to_cart', 'goods=' + goods.toJSONString(), addToCartResponse, 'POST', 'JSON');
}
2:控制列表页面的购买.
在列表页面中,增加一个框



<form action="JavaScript:addToCart1({$goods.goods_id})" method="post" name="ECS_FORMBUY{$goods.goods_id}" id="ECS_FORMBUY{$goods.goods_id}" >
  
   购买数量:<input name="number{$goods.goods_id}" type="text" id="number{$goods.goods_id}" value="1" size="4"   class="formBorder"/><br />
  
  
   <a href="javascript:addToCart1({$goods.goods_id})"><img src="images/but_buy.jpg"></a>
   <a href="javascript:;" id="compareLink"quotes"}','{$goods.type}')"><img src="images/but_comp.jpg"></a></form>
调用addToCart1函数.
3:推荐页面


在common.js中增加函数addToCart2


function addToCart2(goodsId, parentId)
{
   var goods        = new Object();
   var spec_arr     = new Array();
   var fittings_arr = new Array();
   var number    = 1;
   var t = "number"+goodsId;
   number = document.getElementByIdx_x("number_"+goodsId).value;
   goods.spec     = spec_arr;
   goods.goods_id = goodsId;
   goods.number = number;
   goods.parent = (typeof(parentId) == "undefined") ? 0 : parseInt(parentId);
   Ajax.call('flow.php?step=add_to_cart', 'goods=' + goods.toJSONString(), addToCartResponse, 'POST', 'JSON');
}
在recommend_new.lbi,recommend_best.lbi等页面中,需要增加输入框.调用次函数.



<form action="javascript:addToCart2({$goods.id})" method="post" name="ECS_FORMBUY_{$goods.id}" id="ECS_FORMBUY_{$goods.id}" >
  
   购买数量:<input name="number_{$goods.id}" type="text" id="number_{$goods.id}" value="1" size="4"   class="formBorder"/><br /><a href=
"javascript:addToCart2({$goods.id})"><img src="images/but_buy.jpg"></a></form>
最后完成了购买数量的控制。




51可用模板(代码)网站专为广大站长朋友提供精品模板与代码,同时免费提供网站收录。
本站域名: WWW.51KYDM.COM    联系方式:QQ:182468923    手机:18111646936
本站关键词:网站链接收录网址收录入口网站免费提交收录网站收录提交入口    网站地图
51可用模板
展开