php – 在Codeigniter购物车类中添加到购物车
发布时间:2020-12-13 22:30:06 所属栏目:PHP教程 来源:网络整理
导读:感谢您抽时间阅读.我一直在使用代码点火器的购物车类作为基本的购物车,但我有一个小问题.将项目添加到购物车后,我将用户重定向到结帐页面,但是当我单击浏览器时,项目将被删除.我知道这是因为我有?php echo anchor('cart',' strong‘.$this- cart- total_ite
感谢您抽时间阅读.我一直在使用代码点火器的购物车类作为基本的购物车,但我有一个小问题.将项目添加到购物车后,我将用户重定向到结帐页面,但是当我单击浏览器时,项目将被删除.我知道这是因为我有<?php echo anchor('cart','< strong>‘.$this-> cart-> total_items().’< / strong> item(s)’)? >在标题中,它在返回时递减.这真烦人,我想解决它.
这是处理表单的控制器 public function process () { if($this->input->post('submit')) { $product = $this->products_model->getProductRow($this->input->post('productid')); $data = array( 'id' => $product['id'],'qty' => 1,'price' => $this->product_helper->calcPrice($product['id']),'name' => $product['name'] ); $this->cart->insert($data); redirect('cart'); //have tried using redirect('cart',303); but doest do anything //have also tried flusing the buffer } else redirect('seatcovers');} 我在这里缺少一些微不足道的东西,或者这是否需要在CI的购物车类中进行更改? 非常感谢 解决方法
我知道有点旧但我有同样的问题,问题是该库有一个正则表达式来限制项目名称
class CI_Cart { // These are the regular expression rules that we use to validate the product ID and product name var $product_id_rules = '.a-z0-9_-'; // alpha-numeric,dashes,underscores,or periods var $product_name_rules = '.:-_ a-z0-9'; // alpha-numeric,colons or periods 更改或创建自己的自定义购物车库 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Cart extends CI_Cart { function __construct() { parent::__construct(); $this->product_name_rules = 'dD'; } } 我在这里找到了解决方案http://darrenonthe.net/2011/05/03/cant-add-products-to-codeigniter-shop-cart-class/? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |