News:

Looking for documentation? Take a look on our wiki

Main Menu

Add several email attachments to order confirmation

Started by Belgaron, March 08, 2017, 16:33:07 PM

Previous topic - Next topic

Belgaron

Hello,
I´d like to add three PDF documents to the order confirmation email. These PDF´s should not be sent with any other email.
I am using Virtuemart 3.0.18 and Joomla 3.6.5. How can I achieve that and what files do I need to modify?

kishoreonwork

you need to edit administrator\components\com_virtuemart\models\order.php

line near to 1695 you will see below code

// Send the email
$res = shopFunctionsF::renderMail('invoice', $order['details']['BT']->email, $vars, null,$vars['doVendor'],$this->useDefaultEmailOrderStatus);


Just above this add following code
if( $order['order_status']=='C'){  //Only for confirmed order

$vars['mediaToSend'][] = 'Full path to your file1';
$vars['mediaToSend'][] = 'Full path to your file2';
$vars['mediaToSend'][] = 'Full path to your file3';

}



Please let me know if this help.

Before making the chnages please make backup of this file.

Thanks
Kishore
I am available for paid joomla and virtuemart consulting.
http://www.kishoreweblabs.com/
skype kishore2607

Belgaron

Hello kishoreonwork,
thank you for your help. Unfortunately it does not work, the documents are not added as attachments. Do you have any other proposal?

kishoreonwork

Yes there is a problem in the code ,as there are some override in email render function.

Here is the new code which i have tested and working fine for me.

1)The file is components/com_virtuemart/views/invoice/view.html.php

the function name is "renderMailLayout"  look for below code near line no  306

if(!empty($attach) and !$doVendor and in_array($this->orderDetails['details']['BT']->order_status,VmConfig::get('attach_os',0)) ){
$this->mediaToSend = VMPATH_ROOT.DS.'images'.DS.'stories'.DS.'virtuemart'.DS.'vendor'.DS.VmConfig::get('attach');
}



Replace it with

if(!empty($attach) and !$doVendor and in_array($this->orderDetails['details']['BT']->order_status,VmConfig::get('attach_os',0)) ){

$attachment=explode(',',$attach);

foreach($attachment as $file){
$this->mediaToSend[] = VMPATH_ROOT.DS.'images'.DS.'stories'.DS.'virtuemart'.DS.'vendor'.DS.$file;

}


}


2) Now in virtuemart administration backend in configuration ->checkout ->General mail attachment
Enter comma separated file name for your attachments


Thanks
Kishore


I am available for paid joomla and virtuemart consulting.
http://www.kishoreweblabs.com/
skype kishore2607

Milbo

When I read your first answer, I wanted to interfer and explain that we have that already, but only for one pdf.

It is a nice idea to extend the config possibilities by using explode. We use this already for other options. I think we should check all places and use always the same sign. I fear we use sometimes comma, sometimes semicolon, sometimes "new line".
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Belgaron

Hi kishoreonwork, that solution works perfect thank you so much. This solves a long standing issue for me and it is now really easy to add documents from the backend.  :D

Is it possible to override the com_virtuemart/views/invoice/view.html.php ?

I tried to put it in mytemplate/com_virtuemart/invoice/view.html.php but it seems not to work.

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

kishoreonwork

I am available for paid joomla and virtuemart consulting.
http://www.kishoreweblabs.com/
skype kishore2607

Belgaron

Thank you Milbo for adding the new code. That makes life a lot easier.