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?
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
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?
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
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".
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.
It is added to vm3.2, wait for the vm3.2.1
Thanks for adding this code to new VM
Thank you Milbo for adding the new code. That makes life a lot easier.