如何在 opencart 版本 1.4.9.4 中以编程方式将产品添加到购物车

问题描述

我正在 opencart 1.4.9.4 中自定义我的客户商店。我想将产品动态添加到购物车。我尝试使用

$this->cart->add($giftvoucher],$quantity,$option);

但它不起作用

解决方法

你必须检查是否有选项 使用 ajax 的简单方法 如果你的意思是你想要 json 代码,就是这样:

                $this->cart->add($this->request->post['product_id'],$quantity,$option,$recurring_id);

如果你没有 $recurring_id 就删除它