我正在调整现代主题以创建一个新主题以供使用。
我需要显示客户购物篮中的所有产品。我有这段代码,目前它最多只显示三个项目。我可以使用其他命令代替 getRecentItems()
来显示购物篮中的所有商品吗?我尝试使用 getAllItems()
但这似乎没有任何作用。
<?php $items = $this->getRecentItems();?>
<?php if(count($items)): ?>
<ol id="cart-header" class="mini-products-list">
<?php foreach($items as $item): ?>
<?php echo $this->getItemHtml($item) ?>
<?php endforeach; ?>
</ol>
<?php else: ?>
<?php echo $this->__('There are no items in your shopping Basket.') ?>
<?php endif ?>
有什么想法吗?
最佳答案
checkin 系统 > 配置 > 结账 > 购物车侧边栏
有一个设置可以设置迷你购物车中可见的产品数量。
最大显示最近添加的项目 默认情况下为 3。将其增加到您想要的数量,或者更确切地说是一个较高的数字,以始终显示购物车中的所有产品。
编辑:要根据您的评论覆盖默认的 magento 行为,您可以使用以下内容。
<?php
$session= Mage::getSingleton('checkout/session');
$items = $session->getQuote()->getAllItems();
?>
<?php if(count($items)): ?>
<ol id="cart-header" class="mini-products-list">
<?php foreach($items as $item): ?>
<?php echo $this->getItemHtml($item) ?>
<?php endforeach; ?>
</ol>
<?php else: ?>
<?php echo $this->__('There are no items in your shopping Basket.') ?>
<?php endif ?>
关于php - Magento 获取购物车中的所有产品而不是最新的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14062310/