如何在Codeigniter中验证库购物车

时间:2020-08-12 08:42:10

标签: php codeigniter cart

我在这里发现了一些问题。

我在codeigniter中使用购物车功能。而且我希望我的商店不能在1个购物车中插入其他产品。

示例:我的产品是T恤,我希望客户仅将1件产品添加到购物车1尺寸。如果购买尺寸为M的产品A的客户并且想要尺寸为L的产品B的客户,则系统显示警告“产品必须为M而不是其他尺寸”。客户可以购买尺寸为M而不是其他尺寸的产品A和B。

这是我的控制器:

public function buy()
    {
        $id = $_POST['id'];
        $price = $_POST['price'];
        $name = $_POST['name'];
        $category = $_POST['category'];
        $stock = $_POST['product_stock'];
        $img_path = $_POST['img_path'];
        $content_product = $_POST['content_product'];
        $size = $_POST['size'];

        $data = array(
                    'id' => $id,
                    'qty' => $stock,
                    'price' => $price,
                    'name' => $name,
                    'category' => $category,
                    'img_path' => $img_path,
                    'content' => $content_product,
                    'size' => $size
                );

        $this->cart->insert($data);
                    
        if($size !='size'){
           echo "<script>('The Size Produt Must Be Same !')</script>";      

        }else{
        redirect('shopping');
        }
        
    }

很抱歉,我的脚本没有用,因为我只是尝试在我知道的地方

0 个答案:

没有答案
相关问题