0

So on my customer account registration form: domain.com/customer/account/create/ I would like to set the newsletter subscription checkbox, so it is already checked.

So I have looked in the register.phtml code app/design/frontend/base/default/template/customer/form/register.phtml and at lines 60 to 76 it has this code:

Added code to make registration box have the tick box automatically ticked

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

and

<li class="control">
  <div class="input-box">
   /* added with the additional code above */
   <input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" checked="checked" class="checkbox" />
...

It looks as though this should do what I want but on my live site, it isn't working. I even took out the /* text */ as I thought this may have an effect but it had no effect.

Any suggestions are most welcome. Thank you.

1 Answer 1

0

Don't change any code in the base folder, since this contains Magento original files that will be used as a "backup" for your website. Also, if you update your Magento version, this "core" files will be replaced.

If you are using a custom theme, go to the folder:

app/design/frontend/[theme_company]/[theme_name]/template/customer/form/register.phtml

If you don't have any installed theme, the folder should be:

app/design/frontend/default/default/template/customer/form/register.phtml

Make the changes in one of these files and should work fine. Don't forget to undo all changes in the base folder that you made. Also, you may need to clear the cache to see the changes.

6
  • Thank you @Bruno Monteiro for your response. I've undone the changes I made and now copied the register.phtml file to my custom (Ultimo theme) folder using the correct hierarchy. But when I try and change the code, it doesn't seem to change my live site. Even when I change the Base file it doesn't change either, so I am a bit stuck. Do you know what changes I need to make so I can make the checkbox already ticked by default?
    – j_granty
    Commented Jul 28, 2016 at 0:10
  • I turned on template path hints and where my checkbox is located on my customer/create page, it looks like the file is brought in from frontend/base/default/template/persistent/customer/form/register.phtml but I've never come across the <strong>'persistent'</strong> folder in my Magento directory. Can you shed any more light on this please? Many thanks.
    – j_granty
    Commented Jul 28, 2016 at 0:42
  • Are you cleaning the cache? You can do that manually going in the folder var/cache and delete everything there. Commented Jul 28, 2016 at 15:17
  • 1
    Also, is your theme set to be used in your admin panel? Magento will get the files from your theme folder (if you are using the theme), if not will get from the default (not the base) folder. Magento just go to the base folder when all other options fail for any reason. If you are using a development environment or if is OK to make some changes, I would completely remove the checkbox field, clear the cache and go to the page again. This way you can confirm if you are updating the right file. Commented Jul 28, 2016 at 15:20
  • Hi @Bruno Monteiro, your comments helped me alot. I had another look through my folder structure and found the correct register.phtml file. It was inside a folder called 'persistent' (which I didn't see first time I looked), this was found in the base folder. Next I duplicated the folder structure to my theme folder and from there I managed to make the checkbox set to a default of ticked. Thanks again for your help! I will mark this post as solved. =)
    – j_granty
    Commented Jul 28, 2016 at 22:10

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.