filter/edit order history print output

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

      THE BELOW IS ONLY RELEVANT IF USING THE DEFAULT PRINT TEMPLATE – FOR ALL OTHER (DRAG/DROP) TEMPLATES, USE THE EDITOR (CSS | DRAG/DROP ) TO ADJUST
      NOTE: PLAINTEXT TEMPLATES ARE NOT STYLABLE via CSS (it’s plaintext)

      also see the help screen on that templates admin page

      there are several filters available in the printed output of your order history. essentially, there are 3 sections

      a) css / layout (colors, fonts, borders etc)
      b) display of various parts (default being that all are printed , but can be removed as required with filters)
      c) sections like header, order summary , order details/items etc , that can be globally rearranged/removed

      (a – css / layout) examples

      to add your own or change existing css:
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_css','myprefix_add_css');
      function myprefix_add_css($style){
      // *** to change overall font/fontsize (default being font-size:12px;font-family:Arial, Verdana, Helvetica, sans-serif)***  //
      $style['global_font']='html,body,table,tbody,tr,td,th,span{font-size:10px;font-family: Verdana, Helvetica, sans-serif}';
      // *** to change item font size (default being 100%)***  //
      $style['items_fontsize']='#items .item td{font-size:120%}';	
      // *** to remove exiting ['table'] style for instance ***  //
      unset($style['table']);
      // *** to change exiting  ['table'] style for instance ***  //
      $style['table']='table{// use your own css declaration //}';
      // *** to add new/your own css declaration***  //
      $style['custom']='// add some custom css declaration //';
      /*so, to make any additional info bigger (added ingredients if used for example) */	
      $style['custom']='.itemaddinfo>td{font-size:120%}';
      // *** to remove ALL css *** //
      $style=array();
      return $style;
      }
      

      (b – parts) examples

      (b) header

      to add, amend or delete header elements (examples) :
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_header_output','myprefix_amend_header_elements');
      function myprefix_amend_header_elements($elements){
      // to add something to footer
      $elements['tableFooter']='<tfoot><tr><td colspan="2">something</td></tr></tfoot>';
      // to remove address for example
      unset($elements['address']);
      return $elements;
      }
      

      (b) overview

      to add, amend or delete different elements (examples) :
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_overview_output','myprefix_amend_overview_elements');
      function myprefix_amend_overview_elements($elements){
      // to remove payment_type line
      unset($elements['payment_type']);
      // to remove payment_method line
      unset($elements['payment_method']);
      // to remove transaction id line
      unset($elements['transaction_id']);
      // to add something after transaction_id
      $elements['transaction_id'].='<tr><td>something left</td><td>something right</td></tr>';
      // to move transaction_id before payment_type (.ie after delivery)
      $tid=$elements['transaction_id'];//store var
      unset($elements['transaction_id']);//remove original
      $elements['pickup_delivery'].=$tid;//append after delivery
      // to add something to footer
      $elements['tableFooter']='<tfoot><tr><td colspan="2">something</td></tr></tfoot>';
      // to remove table header for example
      unset($elements['tableHeader']);
      return $elements;
      }
      

      (b) customer details

      to add, amend or delete different customer data (examples) :
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_customer','myprefix_amend_customer_details');
      function myprefix_amend_customer_details($details){
      //	do a print_r($details); to get all keys - they will be something like [cname],[cemail],[caddress],[ctel] etc
      // so to remove the line containing the email address (key being [cemail]) do:
      unset($details['cemail']);
      return $details;
      }
      

      to add, amend or delete different elements (examples) :
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_customer_output','myprefix_amend_customer_elements');
      function myprefix_amend_customer_elements($elements){
      // to add something to footer
      $elements['tableFooter']='<tfoot><tr><td colspan="2">something</td></tr></tfoot>';
      // to add something after items
      $elements['tableBodyItems'].='<tr><td>something </td><td>something </td><td>something </td></tr>';
      // to remove table header for example
      unset($elements['tableHeader']);
      return $elements;
      }
      

      remove or alter customer details labels for example:

      
      add_filter('wppizza_filter_print_order_customer_detail','myprefix_amend_customer_data',10,3);
      function myprefix_amend_customer_data($detail,$key,$item){
      //* to remove all labels in front of all customer details**
      $detail='<tr><td colspan="2" >'.$item['value'].'</td></tr>';
      //* to remove only the label for email in front of all customer details**
      if($key=='cemail'){
      $detail='<tr><td colspan="2" >'.$item['value'].'</td></tr>';
      }
      //* to alter the label in front of emails details**
      if($key=='cemail'){
      $detail='<tr><td>- my new label--</td><td>'.$item['value'].'</td></tr>';
      }
      return $detail;
      }
      

      (b) order details

      to delete the single item price for example in each element:
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_single_item','myprefix_amend_item');
      function myprefix_amend_item($item){
      // to remove pricesingle after item name/size
      unset($item['pricesingle']);
      //to remove category name
      //(only applicable if enabled in wppizza->layout Group, sort and display menu items by category)
      unset($item['category']);
      return $item;
      }
      

      to add, amend or delete different elements (examples) :
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_items_output','myprefix_amend_items_elements');
      function myprefix_amend_items_elements($elements){
      // to add something to footer
      $elements['tableFooter']='<tfoot><tr><td colspan="2">something</td></tr></tfoot>';
      // to add something after items
      $elements['tableBodyItems'].='<tr><td>something </td><td>something </td><td>something </td></tr>';
      // to remove table header for example
      unset($elements['tableHeader']);
      return $elements;
      }
      

      (b) order summary

      to add, amend or delete different elements (examples) :
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_summary_output','myprefix_amend_summary_element');
      function myprefix_amend_summary_element($elements){
      // to add something to footer
      $elements['tableFooter']='<tfoot><tr><td colspan="2">something</td></tr></tfoot>';
      // to add something after summary
      $elements['tableBodySummary'].='<tr><td>something left</td><td>something right</td></tr>';
      // to remove table header for example
      unset($elements['tableHeader']);
      return $elements;
      }
      

      (c – sections) examples
      to reorder the different parts (or omit one or more entirely ):
      in your theme’s functions.php:

      
      add_filter('wppizza_filter_print_order_output','myprefix_amend_output');
      function myprefix_amend_output($parts){
      // to reorder just arrange the order as required below. for example, to have customer details last
      $newparts['header']=$parts['header'];
      $newparts['overview']=$parts['overview'];
      $newparts['items']=$parts['items'];
      $newparts['summary']=$parts['summary'];
      $newparts['customer']=$parts['customer'];
      return $newparts;
      //to - for example - omit the header entirely
      unset($parts['header']);
      return $parts;
      
    Viewing 1 post (of 1 total)
    • The topic ‘filter/edit order history print output’ is closed to new replies.