Reputation: 180
I am adapting the modern theme to create a new theme to use.
I need to display all the products in the customers basket. I have this code and currently it only displays up to three items. Is there a different command I can use instead of getRecentItems()
to display all the items in their basket? I tried using getAllItems()
but this does not seem to do anything.
<?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 ?>
Any Ideas ?
Upvotes: 8
Views: 8748
Reputation: 19
The Mage_Checkout_Block_Cart_Sidebar method getRecentItems() accepts a count param, just call it in this way to retrieve the full cart items.
<?php $items = $this->getRecentItems(10000);?>
Upvotes: 1
Reputation: 1702
I agree with utility. And thank you for sharing on the Shopping Cart Side Bar part. I had a module that list the cart items in the checkout page. Here is my code for your reference.
$quoteObject = $this->getQuote();
foreach($quoteObject->getAllItems() as $item)
{
//do what you want here.
}
Hope this helps.
Upvotes: 0
Reputation: 1234
Check in System > Configuration > Checkout > Shopping Cart Side Bar
There is a setting to set the number of products that can be visible in the mini cart.
Maximum Display Recently Added Item(s) by default is 3. Increase it to what you want it to be or rather a high number to always show all products in the cart.
EDIT: To override the default magento behavior based on your comments you could use the following.
<?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 ?>
Upvotes: 19