6

How to check current page is Customer Account page or not?

I have used this but it's only for My Account Page

<?php $action = Mage::app()->getFrontController()->getAction();
echo $action->getFullActionName('_');
if($action->getFullActionName('_')=="customer_account_index")
{

}?>

4 Answers 4

2

You can try below code, for customer dashboard links below handler is alwasy there, so you can check below handler

if(in_array('customer_account',$this->getLayout()->getUpdate()->getHandles())){
  // your code 
}
3
  • @KetanKpBorada You are always welcome Feb 1, 2017 at 9:57
  • will it works when i install new extension regarding customer. i.e-Testimonial Tab, Zendesk Tab, My Quotation Tab?? Feb 1, 2017 at 10:02
  • its depand on the extension but this works with default Feb 1, 2017 at 10:04
3

you can add check with getModuleName

<?php $modulename = Mage::app()->getRequest()->getModuleName();

if($modulename=="customer" && Mage::getSingleton('customer/session')->isLoggedIn())
{

}?>
1
  • Good logic but it also not works for review/customer/,sales/order/history/,/wishlist etc. Feb 1, 2017 at 9:54
1

Please use bellow code to identify my account page :

$handle= $this->getLayout()->getUpdate()->getHandles();
if(in_array('customer_account',$handle) && in_array('customer_logged_in',$handle)){
 //your code here for my account page.
}
0

You have to add all condition for all action of account pages like below:

<?php $action = Mage::app()->getFrontController()->getAction();
if($action->getFullActionName('_')=="customer_account_index" || $action->getFullActionName('_')=="customer_account_edit" || $action->getFullActionName('_')=="customer_address_new")
{

}?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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