filter/edit header of html emails

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #6086
    Olly
    Admin & Mod

      as of v2.11.5.4 you can do the following instead of editing the html email template directly.
      in your theme’s functions.php:

      for the main header:

      
      /**customise the first header tr in html emails - typically the site title **/
      add_filter('wppizza_filter_htmlemail_head', 'my_html_email_header_filter',10,6);
      function my_html_email_header_filter($headertr, $styles, $labels, $transactiondate, $gatewaylabel,$transactionid) {
      /*
      @headertr			=>	string/tr to output
      @styles				=>	array of style declarations. you can use add_filter(wppizza_filter_html_email_style, my_style_filter) on those too
      @labels				=>	array of various lables set in localization you could use [not used by default here]
      @transactiondate	=>	str of transaction date [not used by default here]
      @gatewaylabel		=>	str of gatewaylabel [not used by default here]
      @transactionid		=>	str transactionid [not used by default here]
      */
      /*
      by default this would output the following
      $headertr='<tr><td colspan="2" style="'.$styles['mailPadding']['30'].';text-align:center;'.$styles['mailHeaderBackgroundImage'].';background-color:'.$styles['mailHeaderBackgroundColor'].';"><h1 style="font-size:160%;color:'. $styles['mailHeaderTextColour'].';">'.get_bloginfo().'</h1></td></tr>';
      */
      /*
      in it's simplest form you could do this instead
      */
      $headertr='<tr><td colspan="2" style="/*[some-styles like margin,padding, background etc etc]*/">[some text]</td></tr>';
      return $headertr;
      }
      

      for the info underneath the main header, before client/customer details

      
      /**customise the second to fifth header tr in html emails -  typically some tex label, and other order information**/
      add_filter('wppizza_filter_htmlemail_head_info', 'my_html_email_header_info_filter',10,6);
      function my_html_email_header_info_filter($infotr, $styles, $labels, $transactiondate, $gatewaylabel,$transactionid) {
      /*
      @infotrs			=>	array of trs to output
      @styles				=>	array of style declarations. you can use add_filter(wppizza_filter_html_email_style, my_style_filter) on those too
      @labels				=>	array of various lables set in localization you could use
      @transactiondate	=>	str of transaction date
      @gatewaylabel		=>	str of gatewaylabel
      @transactionid		=>	str transactionid
      */
      /*
      by default this is made up of the following
      $infotr['orderlabel']='<tr><td colspan="2" style="'.$styles['mailPadding']['20x0x0x15'].'">'.$labels['order_details'].'</td></tr>';
      $infotr['transactiondate']='<tr><td colspan="2" style="'.$styles['mailPadding']['2x0x0x15'].'">'.$transactiondate.'</td></tr>';
      $infotr['paymentdetails']='<tr><td colspan="2" style="'.$styles['mailPadding']['2x0x0x15'].'">'.$labels['order_paid_by'].' '.$gatewaylabel.' ('.$transactionid.')</td></tr>';
      $infotr['devider']='<tr><td colspan="2" style="'.$styles['mailDivider'].'">&nbsp;</td></tr>';
      */
      /*
      so if , for example, you want to add some text after the transaction date (i.e the second tr here, you could do the following
      */
      $infotr['transactiondate']='<tr><td colspan="2" style="'.$styles['mailPadding']['2x0x0x15'].'">'.$transactiondate.' [my additional text]</td></tr>';
      /*
      or if you want to insert another row after the order label
      */	
      $infotr['orderlabel'].='<tr><td colspan="2">[my additional row]</td></tr>';
      /*
      or if you want to get rid of the devider
      */	
      unset($infotr['devider']);
      return $infotr;
      }
      
    Viewing 1 post (of 1 total)
    • The topic ‘filter/edit header of html emails’ is closed to new replies.