2017-12-27 87 views
1

我想在首页购物车中显示产品的总重量。我可以看到Opencart使用此代码显示购物车页面中的总重量:Opencart如何在迷你车中显示车重?

<h1>{{ heading_title }} 
     {% if weight %} 
     &nbsp;({{ weight }}) 
     {% endif %} </h1> 

我试图使用该功能,但没有成功。 有没有办法做到这一点?

谢谢。

回答

1

是的,cart图书馆有一个功能getWeight,你可以使用它。 你需要编辑这两个文件:

catalog\controller\common\cart.php 

查找:

public function index() { 

添加后:

:在

if ($this->config->get('config_cart_weight')) { 
    $data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point')); 
} else { 
    $data['weight'] = ''; 
} 

然后

catalog\view\theme\default\template\common\cart.twig 

添加要显示它:

{% if weight %}Weight: {{ weight }}{% endif %} 

您可能需要清除ocmodvqmodtwig缓存。

+0

谢谢你,你知道我该如何添加一个按钮来清理购物车的迷你车? – Arthur

+0

不客气,请将您的问题作为一个新话题提出。 – DigitCart

+0

好的,我现在就做 – Arthur

相关问题