1

I would like to place a static block for specific customer group on the header.phtml file. What is the customer group ID code to place with the block code below? For example the Customer Group ID is 4.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('test-banner-gen')->toHtml(); ?>

Thank you

1
  • Please check i have added answer hope it's work for you.
    – Kul
    Commented Oct 25, 2016 at 22:22

1 Answer 1

5

You can use below code to show static block for particular customer group if customer is logged In.

/* Check if customer is logged in */

        $isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
    /* If customer is logged in */

    if($isLoggedIn):
        /* Get the logged in customer's group ID */
            $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
        /* Check if the logged in customer's group ID matches with the ID you are after */

        if($customerGroupId == 4):
            echo $this->getLayout()->createBlock('cms/block')->setBlockId('test-banner-gen')->toHtml(); 
        endif;
    endif;
0

Your Answer

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

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