edit item display in order, confirmation, history and email templates

WPPizza – A Restaurant Plugin for WordPress Support Code Snippets WPPizza v2.x (read only)
(Code Snippets for v3.x) edit item display in order, confirmation, history and email templates

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

      instead of copying the templates to your theme directory and editing them directly (and therefore not automatically being able to take advantage of any updates in the templates of the plugin), there have now (from v2.10.2+) been a bunch of filters added to the templates you could use in your themes functions.php file instead.

      some examples below

      
      /************************************************************************************************
      *	
      *	
      *	filter menu items in order page, thankyou page (if enabled), order history and emails (html and plaintext)
      *	please note: html tags will not work in plaintext emails, so if you want to use extra html
      *	somewhere, you want to probably use a separate function for wppizza_filter_plaintextemail_item_markup !
      *	
      *	some ideas/examples below	
      *   you can - of course - also set the order of things, add your own key/value pairs etc etc
      *	existing keys for all 4 filters (although depending on markup there might be additional required ones) 
      *
      *	$markup['quantity']	
      *	$markup['name']	
      *	$markup['size']	
      *	$markup['price']	
      *	$markup['price_total']	
      *	$markup['additionalinfo']	
      *************************************************************************************************/
      add_filter('wppizza_filter_order_item_markup','my_wppizza_item_display',10,4);/*order page*/
      add_filter('wppizza_filter_show_order_item_markup','my_wppizza_item_display',10,4);/*show order / thank you page*/
      add_filter('wppizza_filter_orderhistory_item_markup','my_wppizza_item_display',10,4);/*order history*/
      add_filter('wppizza_filter_htmlemail_item_markup','my_wppizza_item_display',10,4);/*html emails*/
      add_filter('wppizza_filter_plaintextemail_item_markup','my_wppizza_item_display',10,4);/*plaintext emails*/
      function my_wppizza_item_display($markup,$item,$itemKey,$orderOptions){
      /**if you do not want to display the single price for example**/
      unset($markup['price']);
      /***if you want to append "stuff " after the name of the item**/
      $markup['name']=$markup['name'].' stuff ';
      /***if you want to prepend "extra " before the quantity of the item**/
      $markup['quantity']='extra '.$markup['quantity'];
      /**if you want to replace the single price with tax rate for example**/
      $markup['price']=$item['taxrate'].'%';
      /**or add the taxrate to the single price**/
      $markup['price']=$markup['price'].' @'.$item['taxrate'].'%';
      /**
      etc etc 
      **/
      return $markup;
      }
      

      if you have enabled a “final confirmation page” [wppizza->form settings] the filter works slightly differently here as the layout is different. i.e like so (the below might not be a useful thing to display as such, but will give you the idea how it works i think:

      
      /***************************************************************
      *
      *	filter confirmation page output (if used/enabled)
      *	let's say we want to display the sales tax rate applied after the single price
      *
      ****************************************************************/
      add_filter('wppizza_filter_confirmation_item_header_markup','my_wppizza_cpage_header',10,2);/**add a label column to the header after quantity*/
      function my_wppizza_cpage_header($markup,$txt){
      /**
      added header column
      $txt holds all your variables in localization you could use as label (print_r($txt) to get keys)
      i.e $txt['item_tax_total'] would get the text you use as label for taxes as set in localization
      of the wppizza plugin
      if the text you want to display is not available as a variable, replace $txt['item_tax_total']
      with something like this __('my text','wppizza') to make it translatable
      **/
      $addHeaderColumn='<th class="wppizza-confirm-item-tax-th">'.$txt['item_tax_total'].'</th>';
      $markup['quantity']=$markup['quantity'].$addHeaderColumn;
      return $markup;
      }
      add_filter('wppizza_filter_confirmation_item_markup','my_wppizza_cpage_item',10,4);/**display the sales tax rate applied to this item*/
      function my_wppizza_cpage_item($markup,$item,$itemKey,$orderOptions){
      /*******
      * $markup=>array of the different bits and pieces that make up the output (print_r($markup) to get the keys)
      * $item=>array of values associated with this item (print_r($item) to get the keys)
      * $itemKey=>string of key
      * $orderOptions=>array of all values set in wppizza->order settings (in case you need this for something print_r($orderOptions) to get the key/value pairs)
      *******/
      /**add a new td after the quantity column which displays the taxrate**/
      $addTaxrateColumn='<td class="wppizza-confirm-item-tax">'.$item['taxrate'].'%</td>';
      $markup['quantity']=$markup['quantity'].$addTaxrateColumn;
      return $markup;
      }
      
    Viewing 1 post (of 1 total)
    • The topic ‘edit item display in order, confirmation, history and email templates’ is closed to new replies.