I would like to display products on site.com/checkout/cart when there are no items in the cart because a lot or visitors click the cart button without having a product in there.

The current code of the noItem.phtml looks like this:

<div class="page-title">
    <h1><?php echo $this->__('Shopping Cart is Empty') ?></h1>
<div class="cart-empty">
    <?php echo $this->getMessagesBlock()->toHtml() ?>
    <?php echo $this->getChildHtml('checkout_cart_empty_widget'); ?>
    <p><?php echo $this->__('You have no items in your shopping cart.') ?></p>
    <p><?php echo $this->__('Click <a href="%s">here</a> to continue shopping.', $this->getContinueShoppingUrl()) ?></p>
    <?php echo $this->getChildHtml('shopping.cart.table.after'); ?>

Make a new template file somewhere in your design folder, and edit the checkout.xml in your layout folder with the following code:

In the layout handle: checkout_cart_index and in the reference <reference name="content"> add another block:

<reference name="content">
    <block type="core/template" name="shopping.cart.table.after" template"path/to/your/template"/>

Now you can add your own html to show products

  • But I don't need to show products on the checkout page, just on the cart page when there is no product added. Magento handles a noItem.phtml file in case there are no products added to cart. – txm Aug 16 '18 at 12:14

I managed to achieve what I wanted and it was pretty easy.

From the admin panel I created a cms/block called noitem_products and pasted the following code which displays products marked as popular on the homepage:

{{block type='catalog/product_list' category_id='44' grid_column_count='3' hide_toolbar='1' products_count='4' template='catalog/product/list.phtml'}

In order to display the products from this block I use the following code in noItems.phtml to call the block:

<p><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('noitem_products')->toHtml(); ?> </p>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.