1控制商城里的产品购买数量 开源系统 更新 2017-07-26 15:23:38 刘杰 控制商城里的产品购买数量 例如一个产品单次购买数量只能是1如何控制会员购买产品的次数 例如一个会员只能购买一次产品(只能有一个订单) 类似于优惠卡 买完东西就不能用了
foreach ($list as $t) { if ($t['uid'] == $this->uid) { $this->msg(fc_lang('不允许购买自己的商品')); } }改成foreach ($list as $t) { if ($t['uid'] == $this->uid) { $this->msg(fc_lang('不允许购买自己的商品')); } /// 判断商品购买数 foreach ($t['goods'] as $item) { if ($item['quantity'] > 1) { // 判断本次购买 $this->msg(fc_lang('本次只能购买一件商品')); } // 判断历史购买 if ($this->db->where('mid', $item['mid'])->where('cid', $item['cid'])->where('uid', $this->uid)->count_all_results(SITE_ID.'_order_buy')) { $this->msg(fc_lang('本商品你已经购买过了')); } } }以上是我的组装思路,没有经过测试,临时手写的,我认为思路是对的