This question already has an answer here:

How can I check if the current page is the checkout cart page?

I tried this, but that does not work. Then it is displayed on all pages.

<?php if(Mage::getSingleton('checkout/cart')): ?>

<?php endif; ?>

marked as duplicate by Keyur Shah, Rakesh Jesadiya, Amit Bera, Raphael at Digital Pianism, 7ochem Feb 14 '17 at 12:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You can use this :

$handle = $this->getLayout()->getUpdate()->getHandles();
    // cart page

Use below code:

$request = $this->getRequest();
 $module = $request->getModuleName();
 $controller = $request->getControllerName();
 $action = $request->getActionName();
 if($module == 'checkout' && $controller == 'cart' && $action == 'index')
   //Cart Page
  • Thanks! I tried that, but that code is still displaying on other pages as well, for example the homepage. – Henk Z Feb 14 '17 at 9:23
  • updated answer check it – Prashant Valanda Feb 14 '17 at 9:27
$requestUrl = Mage::app()->getModuleName() . DS . Mage::app()->getControllerName();
if($requestUrl == 'checkout/cart'){
   //cart page action logic...

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