Thursday, 31 January 2013

Add Newsletter checkBox to Contacts page

add this line to the template/contacts/form.phtml


<li class="control"><input type="checkbox" name="is_subscribed" id="subscription" value="1" title="<?php echo $this->__('General Subscription') ?>" class="checkbox" /><label for="subscription"><?php echo $this->__('General Subscription') ?></label></li>



add the code to app/code/core/Mage/Contacts/controllers/indexcontroller.php


if($post['is_subscribed'] == 1){
$status = Mage::getModel('newsletter/subscriber')->subscribe($post['email']);
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
    Mage::getSingleton('core/session')
       ->addSuccess($this->__('Confirmation request has been sent.'));
}
else {
    Mage::getSingleton('core/session')
        ->addSuccess($this->__('Thank you for your subscription.'));
}
 }      

in function :- public function postAction()

No comments:

Post a Comment