By default, in the VirtueMart 1.1.* Store Information settings you can add only one e-mail address in Contact Information box. All important mails - as new order notifications, for example, will be sent there. What if - for various reasons - you need to add more, than one e-mail address?

Basically, you are out of luck, if you add in the input box a second e-mail address, and separate them with a comma (',', like 'This email address is being protected from spambots. You need JavaScript enabled to view it., This email address is being protected from spambots. You need JavaScript enabled to view it.') when you try to save your settings, you will got an error message saying:

Please provide a valid email address for the vendor contact

So, first of all, you should eliminate this error message, and save the multiple email addresses in the database. Yea, we will do a core hack here, so follow us - on your own risk!

Locating the source of the error message is easy, you can find it quickly by searching in the code. The file you need to hack is

/administrator/components/com_virtuemart/classes/ps_vendor.php

You need to locate this code:

if (!vmValidateEmail($d["contact_email"])) {
$vmLogger->err( 'Please provide a valide email address for the vendor contact.' );
return False;
}

and comment it out for example like this:

/* if (!vmValidateEmail($d["contact_email"])) {
$vmLogger->err( 'Please provide a valide email address for the vendor contact.' );
return False;
} */

By doing this you eliminated COMPLETELY the validation for this field, and now you can save ANYTHING in the database (or almost anything) including comma delimited lists of e-mail addresses. This is fine, if you will be the sole administrator of the site, but if you do this hack for a client, then better play with the vmValidateEmail() function - or do something similar to what we will do later, to break down the netered list in individual e-mail addresses, and validate them one-by-one. But you got the idea, I hope.

So, first step is done, but don't be too happy yet, because the hack is a bit useless right now - the system won't send ANY emails yet, because is not prepared to handle all these e-mail addresses.

The second step is a bit trickier - but still doable. Locate this file:

/administrator/components/com_virtuemart/classes/ps_vendor.php

Search for this code:

// Email Addresses for shopper and vendor
// **************************************
$shopper_email = $dbbt->f("user_email");
$shopper_name = $dbbt->f("first_name")." ".$dbbt->f("last_name");
$from_email = $dbv->f("contact_email");

 

Change it to pick the first e-mail address from the saved list, for example this way:

// Email Addresses for shopper and vendor
// **************************************
$shopper_email = $dbbt->f("user_email");
$shopper_name = $dbbt->f("first_name")." ".$dbbt->f("last_name");
$email = explode(',',trim($dbv->f("contact_email"),','));
$from_email=$email[0];

 

In the above code we picked the very first email ID as a "from" email ID, thus we restored the original functionality of VirtueMart. So if you entered something like in the above example 'This email address is being protected from spambots. You need JavaScript enabled to view it., This email address is being protected from spambots. You need JavaScript enabled to view it.' then the system will send out the mails to the first address, 'This email address is being protected from spambots. You need JavaScript enabled to view it.' as did by default with a single e-mail address entered in the configuration.

Let's handle now the eventual additional addresses too! In the same file:

/administrator/components/com_virtuemart/classes/ps_vendor.php

search for

if ( !$shopper_mail || !$vendor_mail )

Before this line, insert the following code:

if(count($email)>1)
   {
    for($j=1;count($email)>$j;$j++)
    {
     $vendor_mail = vmMail( $from_email, $mosConfig_fromname, $email[$j], $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages, null, $shopper_email);
    }
   }

And you're done! the above code will check, if there are more, than one e-mail addresses entered in configuration, and will send the critical mails to those addresses too. Simple enough? Yea. Just be aware, that this is a core hack!

 

You need to save everything before you attempt to use it. And do it on your risk. And enjoy itWink.

0
0
0
s2sdefault
Category: VirtueMart hacks