如何使用 opencart 2.3 在产品页面中显示/显示产品购物车数量

时间:2021-07-08 22:00:48

标签: opencart product

我使用 OC 2.3 搜索并尝试了各种方法。 我正在尝试在产品页面上显示购物车中已有的单个产品项目 - 有什么想法吗? 谢谢

2 个答案:

答案 0 :(得分:0)

enter image description here [![当前项目 产品页面中的产品][2]][2]

需要显示当前商品页面的单个商品的商品数量。 我输入了下面的代码,但我认为需要在控制器中声明的值。

<?php echo "CURRENT PRODUCT ITEMS IN CART: " . $products_quantity; ?>

答案 1 :(得分:0)

我在catalog/controller/product/product.php中输入了波纹管声明, 它有效,但仅当购物车中有产品时才有效。

foreach ($this->cart->getProducts() as $product) {

            if ($product['quantity']) {
                $products_quantity = $product['quantity'];
                } 
            
            $data['products'] = array(
                'products_quantity'  => $product['quantity']
            );
                
                
$data['products_quantity'] = $products_quantity;

}