Forum Replies Created
- AuthorPosts
- 25 May, 2020 at 5:52 pm in reply to: suggestion for preselect field on checkout coming from URL param #49415
This is exactly the documentation i was looking for.
Thanks Olly!Hi,
in frontend ordering the is no PHP notice, only in Dashboard.
Thanks
Dirk23 May, 2020 at 10:39 pm in reply to: suggestion for preselect field on checkout coming from URL param #49357Any suggestion how to solve this?
Thanks!Hi Olly,
i managed to attach the order data as json on demand but i’m very unhappy to patch the file “wppizza.send-emails.inc.php” directly.
Is there a better way to do this via filter/plugin?This is my patch:
Index: wppizza.send-emails.inc.php =================================================================== --- wppizza.send-emails.inc.php (revision 9754) +++ wppizza.send-emails.inc.php (working copy) @@ -489,6 +489,14 @@ $order_details=$orderDetails->getOrder();/**all order vars => plaintext**/ /*********************************************************** + Add orderdetails as JSON attachment + ***********************************************************/ + $txt .= json_encode($orderDetails->getOrder(), JSON_PRETTY_PRINT); + $orderfilename = 'order'.$orderId.'.json'; + file_put_contents($orderfilename, $txt); + + + /*********************************************************** [set name and email of the the person that is ordering] ***********************************************************/ /*get order details for html too if required*/ @@ -547,7 +555,7 @@ foreach($tpl_recipients as $template_id=>$recipients){ - $mail_result=$this->send_email_execute($recipients, $email_markup[$template_id], $template_id, $order_details['customer'], $no_attachments[$template_id]); + $mail_result=$this->send_email_execute($orderfilename, $recipients, $email_markup[$template_id], $template_id, $order_details['customer'], $no_attachments[$template_id]); /**only return results for main email sent to shop**/ if(!empty($recipients['email_shop'])){ $send_email_result=$mail_result; @@ -554,6 +562,11 @@ } } + // delete temp order file +// if (file_exists($orderfilename)) { +// unlink($orderfilename); +// } + return $send_email_result; } @@ -566,7 +579,7 @@ * @customer_in_cc true to cc, false to send separate email * *********************************************************************************************************************/ - function send_email_execute($recipients, $email_markup, $template_id, $customer_data, $omit_attachments=false){ + function send_email_execute($orderfilename, $recipients, $email_markup, $template_id, $customer_data, $omit_attachments=false){ //global $phpmailer; static $static=0; $static++; /*get plugin options*/ @@ -689,7 +702,11 @@ } } }} - + if(!empty($orderfilename) && is_file($orderfilename)){ + $email_attachments[]=$orderfilename; + } + + /**send as html ? */ $asHtml=!empty($email_markup['html']) ? true : false;
Thanks
DirkHi Olly,
thank’s for always good & fast response!
So this my feature request: Can you add a filter while adding attachments to mail to intercept and userdefined data to mail? In my case just the $order data?something like this (pseudo code for “wppizza.send-emails.inc.php”, line 662 ff):
/*attachments*/
if(!$omit_attachments){
if(!empty($options[‘order’][‘order_email_attachments’])){
foreach($options[‘order’][‘order_email_attachments’] as $attachment){
if(!empty($attachment) && is_file($attachment)){
$email_attachments[]=$attachment;
}
}
}}/**allow adding/changing attachments on the fly***/
$options = apply_filters(‘wppizza_filter_order_email_attachments’, $options , $order, $email_attachments);/**send as html ? */
$asHtml=!empty($email_markup[‘html’]) ? true : false;That filter would allow my plugin to add orderdata in a computer-parseable JSON/XML/CSV format..
Best regards
Dirk - AuthorPosts