php - 如何在opencart中获取cart.php中的附加产品信息?

标签 php mysql opencart2.x

我正在将 opencart 用于 Web 项目,并向所有名为 unit 的产品添加自定义字段。我在 oc_product 表中创建了一个名为 unit 的列。我可以通过添加 data['unit'] = Product_info['unit'] 并通过查询获取它来访问 Product.php 页面上的产品单位,但我想在购物车上访问它.php 页面。我不确定购物车从思想中得到的产品是从哪里来的。所以我不知道到底在哪里添加代码来获取单位。在controller/common/cart.php中有这样的代码块:

      $data['products'][] = array(
            'product_id'=> $product['product_id'],
            'key'       => $product['key'],
            'thumb'     => $image,
            //THIS
            'unit'      => $product['unit'],
            'name'      => $product['name'],
            'model'     => $product['model'],
            'option'    => $option_data,
            'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''),
            'quantity'  => $product['quantity'],
            'price'     => $price,
            'total'     => $total,
            'href'      => $this->url->link('product/product', 'product_id=' . $product['product_id'])
      );

如果您查看上面的代码,请右键单击注释“THIS”,我添加了一行来获取单位。添加该代码不会给我单位,我知道它不会,因为我没有查询它,但我不知道在哪里添加查询。如果我将 $product['unit'] 替换为像“12”这样的简单字符串,我就可以访问购物车页面上的 12。所以问题是我应该编辑哪个查询才能将商品显示在购物车页面上?

最佳答案

我能够弄清楚。转到行 242 int /system/library/cart.php 并在数组中添加以下行

'unit'  => $product_query->row['unit']

关于php - 如何在opencart中获取cart.php中的附加产品信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36751592/

相关文章:

php - 如何使用 Android 拍照并发送到 HTTP POST 请求?

php - 如何在 php docker 容器上安装/启用 pdo-odbc 驱动程序?

php - 单元测试101如何正确测试模型?

php - 需要连接php和mysql

php - 当买家在 OpenCart 下订单时,更新产品 'quantity' 的代码是什么?

mysql - 根据条件插入

php - symfony2 中的自定义集合模板

mysql - 选择重复的 site_id

php - 如何将 opencart 与亚马逊 CDN 集成?

mysql : how to add a where clause superior on text