开发者

Force newsletter subscription in Magento

开发者 https://www.devze.com 2023-01-11 11:08 出处:网络
I am working with Magento, in which I need to require that, if any customer signs up, he/she must be automatically be subscribed to the newsletter.

I am working with Magento, in which I need to require that, if any customer signs up, he/she must be automatically be subscribed to the newsletter.

For instance, in the admin site, if we edit a customer, we get the newsletter checkbox for "Subscribed to Ne开发者_如何学JAVAwsletter?". I want that check box to always be checked.

Please help me out.


One small thing : Check this is legal in the territory you are deploying in.

For instance, several legislations insist marketing emails must default to 'Opt In' not 'Opt Out' - this is likely why Magento has the default set as is.

It is also accepted best practice not to try to 'trick' users into accidentally subscribing to things. It may be better to leave the option as 'Off' and use some other way to display a message to encourage users to subscribe.


The simplest way would be to modify the template and substitute the checkbox with a hidden input which is always set to 1. You need to edit the file /app/design/frontend/your_interface/your_theme/template/customer/form/register.phtml.

Remove this chunk of code:

    <li>
        <input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" <?php if($this->getFormData()->getIsSubscribed()){ ?> checked="checked"<?php }elseif($this->getFormData()->getIsSubscribed == NULL){ ?> checked="checked"<?php }?> />
        <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
    </li>

And add your hidden input just after the other ones near the top of the form:

<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
<input type="hidden" name="is_subscribed" value="1" id="is_subscribed"  />
0

精彩评论

暂无评论...
验证码 换一张
取 消