Add a CMS Block on Magento’s Cart Page

Posted on December 7, 2014 in Development, Web

One of my client’s is running a special promotion in their Magento store and they want to add banner on the shopping cart page with the details of the promotion and to remind the customers to take advantage of it. Specifically, they want to put the banner just above the shopping cart contents table as highlighted in this picture:

Banner on Magento's Shopping Cart Page

There’s a number of ways this can be achieved, including copying the cart.phtml file from the base theme into your own theme and customizing it, but by far the easiest way—and most convenient from the point of view of long-term maintenance—is to utilize your theme’s local.xml layout file.

First, create a CMS static block in Magento’s back end with the promotion image. Then, add this into the local.xml file in /app/design/frontend/your_package/your_theme/layout/:

<layout>
  <checkout_cart_index>
    <reference name="checkout.cart.form.before">
      <block type="cms/block" name="promotion_banner_cart" after="checkout.cart.top_methods">
        <action method="setBlockId"><block_id>your_cms_block_id</block_id></action>
      </block>
    </reference>
  </checkout_cart_index>
</layout>

Here the your_cms_block_id bit is the identifier of the promotion banner CMS block you created in the first step.

You’re all set—admire your shining new banner on the cart page.

Enjoyed this post? Share it with others.
Share on email
Email
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter

Responses (2)

  1. Gustavo
    October 3, 2018 at 6:17 am · Reply

    hello! if I want to the block after the shopping cart and before the discount block. what is the configuration?

    • Richard
      October 3, 2018 at 12:22 pm ·

      Hi Gustavo,

      It’s been quite a while since I’ve worked with Magento and things have may changed since then, so I’m not really sure if I’m honest. I would have to try it myself and test it. You could try something like this and see if that works:

      
        
          
            
              your_cms_block_id
            
          
        
      
      

Leave a reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.