WPPizza – A Restaurant Plugin for WordPress › Support › General Support › Display content in email
- AuthorPosts
- 29 June, 2015 at 12:57 pm #10866
Hey Olly,
I use the wppizza-order-email-html.php to confirm the order. Now I would like to have the content to be displayed below each product in the email as well.
How do i do this ? I assume I can’t just post “<?php the_content(); ?>” as there is no reference to this one product?
Thanks in advance.
<?php /***allow filtering of items (sort, add categories and whatnot)****/ $order_items = apply_filters('wppizza_emailhtml_filter_items', $order_items, 'htmlemail'); foreach($order_items as $itemKey=>$item){ /***allow action per item - probably to use in conjunction with filter above****/ do_action('wppizza_emailhtml_item', $item, $htmlEmailStyle); /**added 2.10.2*/ /**construct the markup display of this item**/ $itemMarkup=array(); $itemMarkup['trtd'] ='<tr><td style="'.$htmlEmailStyle['mailPadding']['2x15'].'">'; $itemMarkup['quantity'] =''.$item['quantity'].'x '; $itemMarkup['name'] =''.$item['name'].' '; $itemMarkup['size'] =''.$item['size'].' '; $itemMarkup['price'] ='['.$currency_left.''.$item['price'].''.$currency_right.']'; $itemMarkup['tdtd'] ='</td><td>'; $itemMarkup['price_total'] =''.$currency_left.''.$item['pricetotal'].''.$currency_right.''; $itemMarkup['tdtr'] ='</td></tr>'; if($item['additional_info']!=''){ $itemMarkup['additionalinfo']='<tr><td colspan="2" style="'.$htmlEmailStyle['mailPadding']['0x15x15x30'].';font-size:90%">'. $item['additional_info'].'</td></tr>'; } /************************************************************************************************** [added filter for customisation v2.10.2] if you wish to customise the output, i would suggest you use the filter below in your functions.php instead of editing this file (or a copy thereof in your themes directory) /**************************************************************************************************/ $itemMarkup = apply_filters('wppizza_filter_htmlemail_item_markup', $itemMarkup, $item, $itemKey, $options['order']); /**output markup**/ echo''.implode("",$itemMarkup).''; ?>
29 June, 2015 at 4:54 pm #10874>assume I can’t just post…
you would be correctbut you can use
$item['postId']
to then get the content for that post id (or anything else you want to get for that id)29 June, 2015 at 4:58 pm #10875PS: BTW, i would suggest you also use the filter “wppizza_filter_htmlemail_item_markup” though instead of editing the template directly
30 June, 2015 at 8:04 am #10885Olly I am always stoked about your quick replies. Respect 🙂
I have added the filter to the functions.php file however not sure how to actually use it. I dont have an extra page or something to setup the email? (right?)
Thanks again.
Regards,
Bart30 June, 2015 at 8:32 am #10886Hey Olly, so far I have tried but failed to pull the content from the product. My coding isnt great at all.
<?php /***allow filtering of items (sort, add categories and whatnot)****/ $order_items = apply_filters('wppizza_emailhtml_filter_items', $order_items, 'htmlemail'); foreach($order_items as $itemKey=>$item){ /***allow action per item - probably to use in conjunction with filter above****/ do_action('wppizza_emailhtml_item', $item, $htmlEmailStyle); /**added 2.10.2*/ /**construct the markup display of this item**/ $itemMarkup=array(); $itemMarkup['trtd'] ='<tr><td style="'.$htmlEmailStyle['mailPadding']['2x15'].'">'; $itemMarkup['quantity'] =''.$item['quantity'].'x '; $itemMarkup['name'] =''.$item['name'].' '; $itemMarkup['size'] =''.$item['size'].' '; $itemMarkup['price'] ='['.$currency_left.''.$item['price'].''.$currency_right.']'; $itemMarkup['tdtd'] ='</td><td>'; $itemMarkup['price_total'] =''.$currency_left.''.$item['pricetotal'].''.$currency_right.''; $itemMarkup['tdtr'] ='</td></tr>'; $itemMarkup['trtd'] ='<tr><td>'; $itemMarkup['postId'] =['postid']; $itemMarkup['tdtr'] ='</td></tr>'; if($item['additional_info']!=''){ $itemMarkup['additionalinfo']='<tr><td colspan="2" style="'.$htmlEmailStyle['mailPadding']['0x15x15x30'].';font-size:90%">'. $item['additional_info'].'</td></tr>'; } /************************************************************************************************** [added filter for customisation v2.10.2] if you wish to customise the output, i would suggest you use the filter below in your functions.php instead of editing this file (or a copy thereof in your themes directory) /**************************************************************************************************/ $itemMarkup = apply_filters('wppizza_filter_htmlemail_item_markup', $itemMarkup, $item, $itemKey, $options['order']); /**output markup**/ echo''.implode("",$itemMarkup).''; ?>
30 June, 2015 at 8:49 am #10887I changed back to the original code and found when ordering, this shows up above the email:
% @%% @%% @%% @%It looks like its three symbols for each ordered product (in this case 4 products)
The only thing that I changed is adding the filter.
30 June, 2015 at 7:09 pm #10895>I changed back to the original code …
never change/edit corefiles. your changes will get lost with the next update>The only thing that I changed is adding the filter.
doesnt look like it to me. you are supposed to add a filter and function that goes with it in your themes functions.php, not editing what is in the plugin
30 June, 2015 at 7:10 pm #10896also, what is this supposed to do ?
$itemMarkup['postId']=['postid'];
30 June, 2015 at 7:18 pm #10897anyway , you should do something along these lines (in your themes functions.php)
function my_extra_markup( $itemMarkup, $item, $itemKey, $options) { /* get content of post */ $content=get_post( $item['postId']); /* add content to markup */ $itemMarkup['content']='<tr><td colspan="2">'.$content->post_content.'</td></tr>'; return $itemMarkup; } add_filter('wppizza_filter_htmlemail_item_markup', 'my_extra_markup', 10, 4);
7 July, 2015 at 10:38 am #10970What I did was copy paste the email .php to the theme folder so I could edit the layout.
I tried adding the filter and then make it show up through the php form but no succes. When i add this filter. What exactly do i put in the php ?
8 July, 2015 at 2:54 am #10972>What exactly do i put in the php ?
nothing (assuming you are talking ab out the template …..emails.php
you add and use the filter in your themes’ functions php as required
16 July, 2015 at 7:24 pm #11082Hey Olli, I’ve added the filter to the functions.php, and put the original wppizza-order-email-html.php file back to make sure not to have any mistakes, but it doesnt display the content below each product, or anywhere.
16 July, 2015 at 8:44 pm #11083i edited the example code a little bit.
try that21 July, 2015 at 8:40 am #11139Absolutely great!! works perfect !
- AuthorPosts
- The topic ‘Display content in email’ is closed to new replies.