【问题标题】:How to show count items in cart in header Open Cart?如何在标题打开购物车中显示购物车中的计数项目?
【发布时间】:2017-01-19 07:23:38
【问题描述】:

我需要在页眉中显示购物车中的商品数量。

我尝试将header.php 文件编辑为:

$products = $this->cart->getProducts();
$data['total'] = count($products);

然后在模板header.tpl中显示这个:

<?php echo $total?>

【问题讨论】:

  • 你的代码是正确的并且对我有用。
  • 请在更改后从管理员刷新修改缓存,然后检查它。请转到 admin > Extensions > Modifications 并单击蓝色的 Refresh 按钮(右上角)以更新系统并检查它。

标签: opencart opencart-module opencart2.3


【解决方案1】:

您的代码应该可以工作,但您也可以使用命令$this-&gt;cart-&gt;countProducts()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    • 2018-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多