6.2.Autoprint
Customisations WPPizza Autoprint
Adjusting print output of selected autoprint template
Your print template selected MUST be set to “Html” to be able to access the css setting
- Go to “Wppizza -> Templates -> Print”
- Locate the template you have selected to use as your autoprint template
- Make sure this template is set to Type->HTML
- Click on the “code” icon to reveal the “Print Order CSS”
- Edit/Adjust the css as required
- To add header/footer – or other – images to the template, see the examples below, adjust as required and add to your css declarations
//some examples regarding logo top, a logo above summary, a logo below summary, assuming logo height is about 60px (alse adjust padding as required //logo top body { background-image: url("http://www.domain.com/[somepath]/logo.png"); background-repeat: no-repeat; background-position: center top; padding-top:60px; } //logo above summary #summary { background-image: url("http://www.domain.com/[somepath]/logo.png"); background-repeat: no-repeat; background-position: center top; padding-top:60px; } //logo below summary #summary { background-image: url("http://www.domain.com/[somepath]/logo.png"); background-repeat: no-repeat; background-position: center bottom; padding-bottom:60px; } //enter something in "Footer : text after summary / totals" in wppizza -> localization and add the logo as in the css examples above //footer localization must not be empty - alternatively simply enter the html in the textbox itself and ignore the css below #footer { background-image: url("http://www.domain.com/[somepath]/logo.png"); background-repeat: no-repeat; background-position: center bottom; padding-bottom:60px; }
wppizza_autoprint_filter_page_format
@param: array
@return: array
add_filter('wppizza_autoprint_filter_page_format', 'myprefix_autoprint_filter_page_format'); function myprefix_autoprint_filter_page_format($pageFormat){ /* adding your own page format for example */ $pageFormat['my_format] = array( 'label' => 'My Format Label',//set some label to identify this in the dropdown 'paper_size' => array(0, 0, 226.77, 'single'),//in points (example here equates to 80mm x 160mm) if 4th parameters is set to single - as opposed to a distinct height in points - , height will be calculated for single page 'page_margin' => array(0.1, 0.4),//in cm (top/bottom, right/left) [1cm == 28.3465 pt] 'page_height_adjustment' => 20, // when forcing single page add an additional value - just to be safe to the calculated pageheight to account for margins. 'orientation' => 'portrait',//portrait or landscape 'font_size' => array(6.5, 6.5),//fontsizes - in points - for monospaced/plaintext and html 'cpl_monospace' => 50,//by default it's 70 characters per line for plaintext templates, this might be too long (depending on font and paper sizeset , so this might need to be less than 70 'thermal' => true,//if its a thermal printer you want to use this template for ); return $pageFormat; }
wppizza_autoprint_filter_printnode_options
dynamically alter printnode options
@param: array
@param: array
@return: array
add_filter('wppizza_autoprint_filter_printnode_options', 'myprefix_autoprint_filter_printnode_options'); function myprefix_autoprint_filter_printnode_options($printnode_options, $order_details){ /* example: alter the api key depending on some order value */ if($order_details['ordervars']['{some-order-value}']['value'] == 'some value'){ $printnode_options['printnode_api_key'] = 'abcdefg....'; } /* example: alter the printnode printer ids (i.e in this example change printer ids to '123456,789456' instead of what is entered in the plugin settings) depending on some order value */ if($order_details['ordervars']['{some-order-value}']['value'] == 'some value'){ $printnode_options['printnode_printer_ids'] = '123456,789456'; } return $printnode_options; }
wppizza_autoprint_filter_printnode_id
dynamically change one of the “Printnode ids” you are printing to (make sure your Api Key is valid for this print id !)
@param: str
@param: array
@return: str
add_filter('wppizza_autoprint_filter_printnode_id', 'myprefix_autoprint_filter_printnode_id'); function myprefix_autoprint_filter_printnode_id($printnode_id, $order_details){ /* example: alter the printnode printer id to 987654 if $order_details is some value and original printer id is 123456 */ if($order_details['ordervars']['{some-order-value}']['value'] == 'some value' && $printnode_id = '123456'){ $printnode_id= '987654'; } return $printnode_id; }
Default css for Autoprint template added on install (in case you would like to reset this to the defaults)
Please note that the absolute font-size will automatically added to this css depending on your plugin settings, therefore the default font-size values are deliberately relative (i.e percentages) here, though you can set things as you wish…
html, body, table, tbody, tr, td, th, span{margin:0; padding:0; text-align:left;} table{width:100%;margin:0 auto 10px auto;} th{padding:5px;border-top:2px solid;border-bottom:2px solid;font-size:120%;white-space:nowrap;text-align:center} td{padding:0 5px;vertical-align:top;} #header tbody > tr > td{text-align:center;padding:0;} #header #site_name td{font-size:250%;} #header #site_url td{font-size:100%;padding-bottom:5px;} #header #site_header td{font-size:130%;} #header #site_address td{font-size:130%;} #overview {table-layout: fixed;} #overview tbody > tr > td{width:50%;word-wrap: break-word;white-space: initial;} #overview tbody > tr > td:first-child{text-align:right} #overview tbody > tr > td.td-ctr{text-align:center;width:100%;} #overview #order_date td {border-top: 2px solid; border-bottom: 2px solid; font-size: 120%; text-align: center;padding: 5px;} #overview #order_id td{font-size:140%} #overview #payment_due td{font-size:140%} #overview #pickup_delivery td{font-size:120%;white-space:normal;text-align:center;width:100%;} #overview #self_pickup td{font-size: 120%;padding: 10px 0;} #overview #admin_notes td{white-space:normal;text-align:center; width:100%; padding:10px 0;} #customer tbody > tr > td{white-space:inherit;} #customer tbody > tr > td:first-child{white-space:break-spaces;} #order th{text-align:left} #order th:first-child,#order th:last-child{width:20px;white-space:nowrap;} #order tbody > tr.items > td{padding-top:5px;font-size:100%; word-break:break-all} #order tbody > tr.items > td:first-child{text-align:center;word-break:initial} #order tbody > tr.items > td:last-child{text-align:right;white-space:nowrap;word-break:initial} #order tbody > tr.divider > td > hr {border:none;border-top:1px dotted #AAAAAA;} #order .item-blog td{padding:5px 2px 5px 2px; border-bottom:1px solid;font-weight:600;font-size:120%} #order .item-category td{padding:5px 2px 2px 2px; border-bottom:1px dashed } #summary {border-top:1px solid;border-bottom:1px solid;} #summary tbody > tr > td{text-align:right} #summary tbody > tr > td:last-child{width:1%;white-space:nowrap;} #footer #footer_note td{text-align:center;width:100%;}
documentor id 5