George George - 5 months ago 12
PHP Question

Get all products in cart instead of most recent

I am adapting the modern theme to create a new theme to use. I am relatively new to Magento but I am finding it to be a great platform for ecommerce. Here is my problem:

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 ?

Answer

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 ?>