Author Topic: Add several email attachments to order confirmation  (Read 716 times)

Belgaron

  • Beginner
  • *
  • Posts: 8
  • A beginner
Add several email attachments to order confirmation
« on: March 08, 2017, 16:33:07 pm »
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

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 32
    • virtuemart expert
  • Skype Name: kishore2607
  • VirtueMart Version: 3
Re: Add several email attachments to order confirmation
« Reply #1 on: March 09, 2017, 23:40:37 pm »
you need to edit administrator\components\com_virtuemart\models\order.php

line near to 1695 you will see below code

 
Code: [Select]
// 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';

}
Code: [Select]


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

  • Beginner
  • *
  • Posts: 8
  • A beginner
Re: Add several email attachments to order confirmation
« Reply #2 on: March 11, 2017, 17:26:57 pm »
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

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 32
    • virtuemart expert
  • Skype Name: kishore2607
  • VirtueMart Version: 3
Re: Add several email attachments to order confirmation
« Reply #3 on: March 17, 2017, 13:12:11 pm »
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

Code: [Select]
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

Code: [Select]
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9161
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add several email attachments to order confirmation
« Reply #4 on: March 18, 2017, 07:47:34 am »
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".
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Belgaron

  • Beginner
  • *
  • Posts: 8
  • A beginner
Re: Add several email attachments to order confirmation
« Reply #5 on: March 18, 2017, 17:35:33 pm »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9161
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add several email attachments to order confirmation
« Reply #6 on: March 21, 2017, 21:10:59 pm »
It is added to vm3.2, wait for the vm3.2.1
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

kishoreonwork

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 32
    • virtuemart expert
  • Skype Name: kishore2607
  • VirtueMart Version: 3
Re: Add several email attachments to order confirmation
« Reply #7 on: March 22, 2017, 02:42:29 am »
 Thanks for adding this code to new VM
I am available for paid joomla and virtuemart consulting.
http://www.kishoreweblabs.com/
skype kishore2607

Belgaron

  • Beginner
  • *
  • Posts: 8
  • A beginner
Re: Add several email attachments to order confirmation
« Reply #8 on: March 24, 2017, 22:08:53 pm »
Thank you Milbo for adding the new code. That makes life a lot easier.