Make email address not required in magento - magento

I'd like to make email address optional during magento registration. I'm going to be adding an additional username attribute that users will be able to log in with (I've already got that part working). What are the steps to do this, or is it even possible? I found an old extension that does what I want I think, but it is out dated. http://www.magentocommerce.com/magento-connect/email-not-required.html
Thanks for any help.

You could do something similar to what the extension does.
"This extension will allow you to add customers without a valid email address. If no email address is present it will insert automatically an email address [customernumber]#[default customer domain]...."
You could create a gmail (or if you use google app for you company email) or a catch all email
Email Format
noemail+[timestamp]-[ipaddress to long]#gmail/yourdomain.com
Then remove the validation js from the email field that make it required in your .phtml.
Then create a custom module that override your checkout controller (assuming one page checkout)
/app/code/core/Mage/Checkout/controllers/OnepageController.php
/**
* save checkout billing address
*/
public function saveBillingAction()
{
...
if (isset($data['email']) && strlen($data['email']) > 3) {
$data['email'] = trim($data['email']);
}
else{
$data['email'] = getNoEmailGen(); // return noemail+[timestamp]-[ipaddress to long]...
}
(You could also do this using JS, where you pre generate the email address (in a hidden field or variable) and if email field is left blank you append/post it before submitting your billing form)

You shouldn't do that because when you order something, transactional mails are going to take place so you can't have users without mail. This should be weird.

Related

how to disable order confirmation mail in a prestashop module?

i want to create a payment module in prestashop and i would like to disable order confirmation mail when a customer validates his order.
i have tried to override the Mail class but it affects the other mail sending. i do not know which file to override and how to do it.
i saw somewhere we can also override PaymentModule but i don't know how to do it
i succeeded to block mail sending by using this :
i use the actionEmailSendBefore hook
$this->registerHook('actionEmailSendBefore')
public function hookActionEmailSendBefore($params){
if($params['template'] === 'order_conf'){
return false;
}
return true;
}
try with create override/classes/PaymentModule.php (and clear cache).
In the override you must put the validateOrder function by commenting on the sending part of the email (to line 206)
Regards

How to deal with non existent emails

I am making an app that allow to register to a newsletter and then manage it.
There is the normal validation if the field is empty, if is email type, unique ecc..
But how can i check if the email really exists?
If someone enter a fake mail, that mail is entered in the database, and this can mess up the database. And there are other annoyance.
Is possible to check if the mail really exists?
Otherwise it is possible to automatically delete an unregistered user after 10 days?
You can create a rule to check if the e-mail format is valid:
$validator = Validator::make(
Input::all(),
array('email' => 'required|email')
);
if ($validator->fails())
{
return "This is not a valid e-mail";
}
But this will only check for the format (name#domain.tld), because there is no way to know if an e-mail address really exists.
Well... this is not entirely true, there is a way: send an e-mail to that address and if you don't get an error message, the address exists, probably.
The best way to do what you need is, when a user creates an account in your system, send him/her a confirmation e-mail, with a link where he/she should click to validate that address. If the account is not validated for x days you delete it. This is a question that might help you on that: Laravel 4: how to make confirmation email?.
About your last question: create an Artisan Command that checks for unvalidated accounts and delete them. Take a look at the docs, it's easy, Laravel does almost all the job for you. And you can run this command once a day using cron or task manager:
php /var/www/your-site-dir/artisan check:accounts
EDIT:
This question will show you how to create a command: Creating and using Laravel 4 commands
And in the method fire() you should do something like:
public function fire()
{
$dt = Carbon\Carbon::now();
User::where('activated', false)
->where('created_at', '<', $dt->subDays(10))
->delete();
}
There are some APIs you can use to verify the validity and existence of emails, but I am not sure how good they are. The free ones usually limit you to something like 10 an hour which probably would not be nearly enough for you, depending on how busy your site is.
Check out http://verify-email.org/register/levels.html
If you are worried about the sheer amount of emails being entered, you could probably log $_SERVER['REMOTE_ADDR'], which would be the client's IP address in the DB on emails and check to make sure that is unique as well before you save additional records to the table.
As far as how to actually validate the existence and validity of the entered email yourself, I believe you'd have to use fsockopen and issue smtp commands to servers. I did find this php class which attempts to do what we are talking about http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt
I doubt it works, but should get you a nice starting point.

Welcome email to include discount code for subscribers

The environment is Magento 1.7.
Basically what I want to achieve is when users subscribes to the newsletter, the system automatically include a discount code in their welcome email. This discount code is for one time use for per account.
Searched around and found a tutorial which is best suit my requirement. Based on my understanding on that tutorial, we need to fetch some values out of the module configuration and user the helper to send an email with a coupon code.
On top of the codes I've made some amendments:
1)
in the file
app\code\core\Mage\Newsletter\controllers\SubscriberController.php
before
$this->_redirectReferer() in newAction()
insert
$helper = Mage::helper(‘subscribereward’);
$promo_value = Mage::getStoreConfig(‘subscribereward/promocode/dollarvalue’);
$promo_min = Mage::getStoreConfig(‘subscribereward/promocode/minpurchase’);
$helper->addPromoCode($email, $promo_value, $promo_min);
2)
in the file
app/code/community/Dg/Pricerulesextended/etc/config.xml
replace
Pricerulesextended/Observer
with
Dg_Pricerulesextended_Model_Observer
I've followed the steps but still can't get it working. Anybody care to shed a light?
Aheadworks has an extension called Follow Up Email, and it does exactly that. Ive set it up for clients where when a customer signs up (or a number of actions) it sends a welcome email with a randomly generated coupon (or standard one).
Also what you could do is just make a coupon code and add it to a welcome email template. Just make a new transactional email and add the coupon to the template. No custom coding required at all.

Extending ion auth to only allow registrations from certain email addresses/domains

I want to extend Ion Auth to only allow certain email addresses to register.
I'm fairly sure I could hack this together and get something working, but as a newbie to codeigniter and ion auth I wish to find out if there is a "proper way" to be doing what I need?
For instance can I "extend" ion auth (so I can update ion auth core files without writing over my changes?).
I noticed there are also hooks including this one (in the register function):
$this->ci->ion_auth_model->trigger_events('pre_account_creation');
Where do these resolve and can I use this one in order to intercept registrations from email addresses which don't match a list of those I wish to register?
If so, how would I do it? I would need access to the $email variable from the register() function.
Or is it just a case of altering the base code from ion auth and not updating it in the future?
Thanks for any help you can give me. Don't worry about the email bit, I'm capable of working out whether an email address matches the required email domains, I'm more interested in what is the best way to go about extending the library.
Tom
EDIT: Hi Ben, thanks for your answer, and thanks for taking the time to have a look at my issue. Unfortunately this hasn't helped.
I guess what you're trying to do there is add a little bit to the sql query a "where in" clause? I guess that the where in bit is incorrect as there isn't a column name.
Also, at this point I can't modify the sql query satisfactorily to produce the required output. e.g. I can add a hook to a function which is literally $this->db->where('1=1') and this outputs this sql in the next query:
SELECT COUNT(*) AS `numrows` FROM (`users`) WHERE `1=1` AND `email` = 'rawr#rawr.com'
The AND email = 'rawr#rawr.com' bit will always still return no rows. It should be OR email = 'rawr#rawr.com', but without editing the Ion Auth core code then I won't be able to change this.
I am starting to suspect (from the last couple of hours of tinkering) that I may have to edit the ion auth core in order to achieve this.
Check out this example: https://gist.github.com/2881995
In the end I just wrote a little form_verification callback function which I put in the auth controller of ion_auth which checked through a list of allowed domains. :)
When you validate your form in the auth controller you add a callback:
$this->form_validation->set_rules('email', 'Email Address', required|callback_validate_email');
You create a method in the controller called validate_email:
function validate_email() {
if (strpos($this->input->post('email'), '#mycompany.com') === false) {
$this->form_validation->set_message('validate_email', 'Not official company email address.');
return false;
} else return true;
}
This will cause the creation of the user to fail, since all rules must pass. You also provide an error message. Just make sure to have this line on the form view side:
echo validation_errors();

Magento 1.4.2 - Set Address Fields During Registration

I am trying to populate address fields during registration, using data from another system. In my observer, I am able to use
$customer = $observer->getCustomer();
$customer->setFirstname($value);
$customer->setLastname($value);
and the information is saved in the database, but
$customer->setStreet($value);
$customer->setPostcode($value);
$customer->setTelephone($value);
do not. How would I set address fields?
Thanks!
Addresses are not stored in the Mage_Customer_Model_Customer object. You should instead do something like:
$address = Mage::getModel('customer/address');
$address->setStreet(...);
...
$customer->addAddress($address);
I found some good posts:
this was easier for me:-)
http://www.pauldonnellydesigns.com/blog/magento-display-address-fields-in-create-an-account/
and longer post:
http://www.magentocommerce.com/boards/viewthread/11110/
It's working, I checked.
I need show fields form address in orders, controller: /checkout/onepage on the page with form login and register (I want add fields personal and address in step register)
Do someone saw code to create for this functionality?

Resources