Recently I got an requirement to add multiple email ID’s seperated by comma(,) in Virtuemart 1.1.9 store setting (Edit Store), so that one vendor can get the purchasing intimation email on his different Email ID’s. But unluckily Virtuemart 1.1.9 do not allows adding multiple email ID’s in store setting.

Virtuemart Store Information

So to fulfill the requirement I added some custom code in Virtuemart admin files. Here is the code and files to modify.

1. Locate – /administrator/components/com_virtuemart/classes/ps_vendor.php
2. Find the below code and comment it like this

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

By commenting the above code virtuemart will stops displaying the warning of invalid email address and now it allows you to add multiple email ID’s seperated with comma(,).

But story doesn’t end’s here, because still virtuemart will not shoots the purchasing email to any of the ID’s added.

3. Now locate – /administrator/components/com_virtuemart/classes/ps_checkout.php
4. Search for the below 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");

5. Replace it with

// 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];

Please note:- In the above code we assigned the very first email ID as a “from” email ID. So for example if you are going to enter abc@gmail.com,xyz@gmail.com then the receiving mail is going to display abc@gmail.com as a “from” email id.

6. Now in the same file search for

if ( !$shopper_mail || !$vendor_mail )

7. And just above searched code line add this 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);
    }
   }

So in the above code we added a loop to grab all email ID’s and shoot them email one by one.

Here you are done, now just go ahead and check the implemented functionality.

Related posts:


  • Rogier

    Hi Amit,

    In Joomla 1.8 there are no such lines in the vendor file? Do you have any suggestions for that?

    • http://www.tips4developer.com Amit

      Hi Rogier
      I am not sure why you mentioned “Joomla 1.8″ but you have to search and replace the code in your Virtuemart folder –
      /administrator/components/com_virtuemart/classes

  • kalai

    Hi,
    I am using joomla 1.5.23 and Virtuemart Component. I am not sure why mail(Purchase Order List) cannot send to sender and receiver. before 2 months got a mail from both sender and receiver. I put emailId in VM edit Store and Joomla Global config . Any suggestion ?

    Thanks

    • http://www.tips4developer.com Amit

      Hi Kalai

      The issue you raised needs admin and code investigation, that might be due to some other plugin conflict or any custom codding added by you or else. So i will not able to help you out on air.

      Thanks

  • https://PolishedGeek.com Polished Geek

    Frankly, we have generally taken a simple, non-technical approach to address this tiny gap in functionality. We try to avoid hacking the core VM code whenever possible. So to make sure multiple people get copies of the invoices, we simply set up a central “orders@domain.com” email address, one that auto forwards to all the other email addresses the client wants to have receive a copy. Then put that one “orders@domain.com” email address in VM’s configuration. Simple solution, no code changes to maintain.

  • Dave

    Great, thanks, I really appreciate it. The second bit should however be ps_checkout.php and not ps_vendor.php

    • http://www.tips4developer.com/ Amit Verma

      Thanks Dev,

      You are absolutely correct, that’s my mistake no updated – “ps_checkout”