douduocuima61392 2016-05-04 15:50
浏览 58

OpenCart在产品块中显示重量

I am currently working on an ecommerce website using opencart, trying to show the weight of each product, in product details template it works, however, when I do the same thing to the product block, it shows undefined variable. This is the site KCityMart

So what I did to show the weight in product details page is this

in file catalog/controller/product/product.php I added this

$data['weight'] = $this->weight->format($product_info['weight'],$product_info['weight_class_id']);

and in /catalog/view/theme/theme/template/product/product.tpl I added this

        <ul class="volume">
          <?php if ($weight > 0) { ?>
          <li><?php echo $weight; ?></li>
          <?php } ?>
        </ul>

and it works. But, when I tried to add this to /catalog/view/theme/theme/template/common/product/default.tpl it shows "undefined variable" error.

What could be the problem? Which part did I miss?

Any input from you all will be very much appreciated. Thanks!

  • 写回答

1条回答 默认 最新

  • doufuxing8562 2016-05-05 06:09
    关注

    What is default.tpl file ? If it's new file then you need to create controller file for it and then do the same thing which you are performed in product controller.

    Assigned weight varible in catalog/controller/product/default.php (Note: If you did not created default.php controller then you need to create) then add following code

    > $data['weight'] = $this->weight->format($product_info['weight'],$product_info['weight_class_id']);
    

    and in /catalog/view/theme/*/template/product/default.tpl add following code in above file.

    <ul class="volume">
          <?php if ($weight > 0) { ?>
          <li><?php echo $weight; ?></li>
          <?php } ?>
        </ul>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口