Developer Documents
Print Template 

Versions 4.0.1 and above for Print Manager for WooCommerce plugin
Adding custom templates:

To init custom templates after loading zprint call wp hook zprint_loaded

this will prevent plugin loading errors by using zprint API add_action('zprint_loaded', 'your_plugin_init_function_name');

Now the zprint_loaded – wp action, will be called after successfully loading zprint.

ZprintTemplates::registerTemplate – static method, require object, implements `ZprintTemplateIndex` interface


required to implement methods in your class:
getName() – return name of your template (string)
getSlug() – return slug (string)
getPath($format) – accept $format (`plain`, `html`), return path to layout file (string)
getFormats() – return assoc array of formats, indicate which formats supports your template type, for example:
['html' => true, 'plain' => false].

Supports custom formats (for example: html): ['key_format' => 'Format name']

For custom options for your template, implement ZprintTemplateOptions interface, renderOptions, processOptions methods.
renderOptions($options) – accept current options assoc array, should render html with input to display them in location form
processOptions($options) – accept current options assoc array, should return new assoc array with data. You can access to new data by $_POST

In each template file you can access a few data and settings variables.
$templateOptions – assoc array include current template options

About shipping settings:

$location_data['shipping']['method'] – show shipping method
$location_data['shipping']['billing_shipping_details'] – show billing and shipping details
$location_data['shipping']['customer_details'] – show customer details
$location_data['shipping']['cost'] – show shipping cost

Additional useful methods and functions:

Zprintget_appearance_setting($name), accept name setting from General tab Print Settings.

Allowed names: logo,Order HeaderCheck HeaderCompany NameCompany InfoOrder Details HeaderFooter Information #1Footer Information #2

Return string or src path for logo

ZprintOrder::getHiddenKeys() return array of keys for order item meta (item_meta from $order->get_items()) which should not display.

You can apply own keys by woocommerce_hidden_order_itemmeta filter.

Plain output format:

class ZprintDocument include static methods to format strings:

Document::centerLine($string) – printer centered string
Document::emptyLine() = print empty string
Document::symbolsAlign($left, $right) – print two string parts joined by spaces in column format
Document::line($string) – print string in line

These methods supports word wrap. You can enable Print symbols for layout debug in location settings. It replaces the align spaces to dots for better layout debug.



Sample Custom Template
Purchase Sample Print Template for Print Manager plugin The sample print template is a shell of a template, allowing you to easily customize for the Print out format. Make changes to the html and css files to customize the layout and content for the print-out.The sample print template is a plugin add-on. If you purchase the sample file. Go to your WordPress admin, plugins page. Click Add New. Upload and Activate the plugin. You will see a plugin installed labeled “Sample Print Template GCP”. The sample custom template is now active for selection and used by the Print Plugin. Now go to Print Settings, click Location tab, and select a print location. Under the template section, click the drop down, you will now see the template “Fancy” for selection.