Make Newsletter checked by default in Magento

So when shopping online, you may notice that when you purchase items or register an account, most of the time you will have an option to sign up to their mailing list. By default, these are normally set to subscribe by default.

Magento for some reason, won’t have this set to subscribe users by default, the checkbox is unticked.

While working on a client site who needed the newsletter to be auto-checked, this little snippet came in handy:

If you want the newsletter opt in on the customer account registration page checked by default, locate this file: /app/design/frontend/<YOUR-THEME>/default/template/customer/form/regist‌​er.phtml

Find this line:

<?php if ($this->isNewsletterEnabled()): ?>

Right below this line, add this:

<?php
$checked = true;
if($this->getFormData()->getEmail()) {
if(!$this->getFormData()->getIsSubscribed()) {
$checked = true;
}
}
?>

A little below that, you’ll see this div:

<div class="input-box">

Replace the input’s code in the div with this:

<input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" checked="checked" class="checkbox" />

Save the file and you’re good to go!

Useful post? Share it

Leave a Reply

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