WooCommerce Automatic Order Printing – Documentation

Documentation index

Plugin installation

This plugin is quite large (over 7Mb), because it contains a lot of code for creating PDF files. Normally, a plugin that you download can be installed and activated in your WordPress dashboard, in the Plugins -> Add New -> Upload page.

If your website gives you an error, telling you that you are not allowed to upload large files, then you can use either of these two methods instead:

  1. Go to the Plugins -> Add New page in your WordPress dashboard. Search for the plugin “Upload Larger Plugins”, and then install and activate it. Then return to the Plugins -> Add New -> Upload page, and try again.
  2. Or, unzip the plugin zip on your computer. You will then have a directory called “woocommerce-printorders”. Upload this whole directory via FTP into your WordPress plugins directory (wp-content/plugins). Then visit the Plugins page in your WordPress dashboard and activate the plugin.

Plugin configuration and usage

There are three things to do to configure this plugin, after you have installed it:

  • Firstly, you need to set up your printer with Google Cloud Print. To learn about how to do this,
    go to the Google Cloud Print website. Come back to this documentation once you have successfully printed a test page to your printer from the Google Cloud Print website.
  • Secondly, you need to connect your website to Google Cloud Print. In your WordPress dashboard, go to the Settings -> Google Cloud Print page. Follow these instructions to set up the connection to Google Cloud Print.
  • Thirdly, you need to choose which print-outs to send to Google Cloud Print when an order is completed. This is done in your WordPress dashboard, in the WooCommerce -> Settings page. You simply need to check all the boxes for all the print-outs which you wish. To customise the print-outs, follow the links shown (and see the section below).

Plugin support and FAQs (including pre-sale FAQs)

WooCommerce Automatic Order Printing

Is this plugin supported and maintained?

Yes. If it ever stops being, then we would withdraw it from sale.

Does this plugin work, and is it being used?

Yes. This plugin started life in the middle of 2013, when it began to be used at a take-away site running on WordPress 3.5 and WooCommerce 2.0. It has been maintained and updated since then, and has been purchased for use with live shops on all subsequent WordPress and WooCommerce versions.

Is Google Cloud Print reliable?

Yes, very. It is backed by the might of Google, has been and supported by many applications across a wide range of operating systems (including PC, Mac, iPhone, iPad, Linux, Android, Chromebook – see: https://www.google.co.uk/cloudprint/learn/apps.html). Many hundreds of printers from many manufacturers also have dedicated built-in support for extra convenience (this is not necessary to use it) – see https://www.google.com/cloudprint/learn/printers.html.

What printers does this plugin work with?

All of them. To be specific, any stand-alone printer that has Google Cloud Print technology built-in is supported without needing an attached computer; and also any printer that you can connect to your computer and print from. (Because, if you can print from your computer, then you can install Google Cloud Print’s driver onto your computer, and then our plugin can print to your printer. Of course, your computer needs to be connected to the Internet and to the printer, in order to be able to receive the print jobs from Google and send them to the printer).

This includes thermal and receipt printers (and a template suitable for narrow printers is included, as well as the ability to customise your templates).

Some printers which don’t have Google Cloud Print built-in (such that they don’t need any other device to drive them) might have a similar system together with the possibility of connecting that system to Google Cloud Print. For example, an HP I once bought came with HP ePrint, and my HP ePrint account could be directly be connected to Google Cloud Print. Though, on the latest HP I bought, it also has Google Cloud Print built in directly as well as HP ePrint.

Of course, whilst Google Cloud Print is a system designed to print to any printer (and has a several-year history of doing so), we cannot warrant this (or anything related – e.g. what’s in the HP you hope to buy) in the case of any particular printer, since it is out of our control; and it is the customer’s responsibility to plan and test any printer purchase. Neither can we comment upon the suitability of any particular printer, unless you are willing to make an arrangement with us to ship it to us for our testing, and cover all the associated costs of doing so (including our time). It’s not realistic for us to take on responsibility relating to printer purchases within the price that the plugin costs!

Do you have a recommended printer, or list of compatible printers?

We do not have a particular recommended printer. Google Cloud Print is designed to be compatible with any printer at all, and it is unfortunately not economic for us to invest in testing different printers, given the pricing expectations of the WooCommerce extensions market.

Any printer at all that you can connect to your computer and print from, and also any stand-alone printer that has Google Cloud Print technology built-in, is suitable for use with this plugin. We are aware of customers successfully using a wide range of makes and models of printers, including different thermal printers.

We first tested and developed the plugin using (among other things) a Star TSP-100 thermal printer in 2013, and are aware of customers happily using this printer still today several years on, but this does not constitute a formal recommendation.

What other WooCommerce add-ons is this plugin compatible with?

We are not aware of any WooCommerce extensions that this plugin is not compatible with. If you find one, then please let us know. In particular, this plugin is compatible with WooCommerce Opening Hours (it displays the customer’s chosen delivery/collection time on its printouts), WooCommerce Invoices and Packing Slips (options set in these plugins for your print-out layout will be honoured), WooCommerce Delivery Notes, WooCommerce Product Add-Ons (it displays the customer’s chosen choices in the print-out), and WooCommerce Currency Switcher (the print-outs will use the proper currency symbols).

An order has been placed, but not printed – what should I do?

Firstly, if relevant, has payment been made for the order? This plugin will instantly print orders made via manual payment methods, even before payment (e.g. cheque, cash, BACS); for other payment methods where payment notification is automated (e.g. PayPal, Stripe, Authorize.Net, etc.), the order is printed when payment is made. If using PayPal, then please check your PayPal account to see that the payment has actually completed – more than one customer has tested using a freshly-created PayPal account that isn’t capable of processing payments yet, because PayPal haven’t lifted the initial restrictions on the account.

Have you selected any templates to actually be printed? Check the plugin settings in WooCommerce -> Settings -> General.

Is your printer yet connected to Google Cloud Print? This plugin sends a print job to Google Cloud Print… until your printer is actually connected to Google Cloud Print, it won’t print anything. Use the “Print” button on this page – https://www.google.com/cloudprint/ – to send test print jobs to your printer via Google Cloud Print.

If your printer is connected to Google Cloud Print, then is your website correctly set up to connect to Google Cloud Print? Go to the Settings -> Google Cloud Print page in your WordPress dashboard and print out a test. If that does not work, then your website is not yet connected to Google Cloud Print.

Is your printer switched on? If it needs to be connected to a computer, then is it – and is the computer switched on? You can check at this link to see if Google Cloud Print has received your job: https://www.google.com/cloudprint/#jobs. If the job is in your Google Cloud Print queue, then this plugin has finished its work – the problem lies further down the line, and you need to look at where.

You can also switch to using “Google Drive” (PDF) as your printer (in the Settings -> Google Cloud Print page) to help work out if the problem is on the road between your WordPress site and Google Cloud Print, or if it’s in between Google Cloud Print and your printer. After you have successfully saved a PDF to Google Drive, you can then try uploading that PDF manually into Google Cloud Print at https://www.google.com/cloudprint/#jobs – does that work? If not, then the problem lies somewhere in between Google Cloud Print and your printer, and isn’t related to this plugin.

You should also make use of the option to send an email with debugging information (in WooCommerce -> Settings -> General), as in this screenshot (send this log to us if requesting support, together with information from all the above items, e.g. your PDF from Google Drive, payment method, etc.):

Email debugging

I wish to print when an order begins processing, not when it is paid

By default, orders made with “manual” payment methods (like cash, cheque or bank transfer) are printed as soon as they are placed. Orders made with automatic methods (which means that the payment gateway can inform WooCommerce that a payment has been made) are not printed when placed, but when the payment signal is made (in WordPress/WooCommerce developer terms, this means “when the ‘payment_complete’ action is called).

If the signal never comes, then it’s best to investigate why not. However, you can, if you prefer, instead make your orders print when they are placed instead, by adding this snipped as an mu-plugin (i.e. add this as a file ending in .php in wp-content/mu-plugins, e.g. wp-content/mu-plugins/print-orders.php):

<?php add_filter('woocommerce_print_orders_print_order_upon_processed', '__return_true');

What is your support and updates policy?

All customers will have access to future releases of the plugin, and for support to help with trouble-shooting, for 12 months.

Whilst we are happy to give general advice as part of support, support has reasonable limits. For example, hiring a developer (if one is available) to extend or customise the plugin for you, or trouble-shooting problems in other plugins on your site (or other things beyond scope – e.g. problems in your printer, or other third-party products), is not included in the purchase price.

Note that this does not affect your ability to continue using an installed plugin. Your installed plugins will remain installed forever. What is limited to 12 months is access to our future work on the plugin and support.

How can I customise this plugin, beyond the obvious settings?

Please see the Customisation and developer information section, in the plugin documentation.

What is your refund policy (software purchases, i.e. plugins)?

We do not have a “no questions asked” refund guarantee. The plugin is priced cheaply, so please read the description carefully and decide whether it is suitable for you. The plugin is not priced to allow us to spend time working together with potential customers on a trial purchase. We will consider refunds only if a defect is found in the plugin which we cannot fix (and for which we are given enough information or access to allow us to establish the existence of the defect), and which is reported within 30 days of purchase. (The right of EU customers to refund a purchase that they have not downloaded, within 14 days of purchase, remains intact).

I haven’t managed to connect my printer to Google Cloud Print. Please can you help?

Unfortunately, the price we have pitched the plugin at does not allow us to help you with any general printing issues. The plugin is a connector between Google Cloud Print and your WordPress site, and we are only specifically able to support that aspect. (To use an analogy, if you buy new tyres for your car, then you’ll understand that the tyre supplier’s service will not include investigating engine issues). To use this plugin, you need to ensure that your printer, any device driving the printer, network and connection to Google Cloud Print are all working, as pre-requisites.

If you want to test that you can manage connecting to Google Cloud Print before you purchase the plugin, then you can use the free Google Cloud Print WordPress plugin to help you.

I have found a problem in the plugin, or a question not answered here. Where do I get personal support?

Please go here and open a support ticket. (Or, if you forgot your login details for your Simba Hosting account, then please go here).

How can I print to more than one printer, or print only if further conditions are fulfilled?

You can choose as many printers as you like, using the settings in your WordPress dashboard in Settings -> Google Cloud Print:

Choosing printers

If you want to filter orders, so that only some orders go to one printer, and some to others, or perhaps to none, then you will need to do a little custom PHP development for this, in order to implement the logic of your particular requirements. (i.e., you’ll either need to write a little PHP code yourself, or hire a PHP coder – somewhere like freelancer.com is an option if you don’t already have a developer. Please note that customised development isn’t part of your plugin purchase – i.e. we can’t put in the time to do this for you as part of your purchase. However, we’ve done 90% of the work for you, below).

The way to do it is to use the google_cloud_print_proceed filter. Note that the $options parameter passed to that filter includes the WooCommerce order ID – so, you can apply arbitrary criteria based upon anything you like concerning the order. Here is a code fragment to start your developer off with:

<?php
add_filter('google_cloud_print_proceed', 'my_google_cloud_print_proceed', 10, 7);
function my_google_cloud_print_proceed($proceed, $printer_id, $title, $document, $prepend, $copies, $options) {

	// If it is not a WooCommerce order, then hand control back
	if (empty($options['order_id'])) return $proceed;

	// Get the order details
	$order_id = $options['order_id'];
	$order = wc_get_order($order_id);
	$order_meta_data = $order->get_meta_data();
	
	/*
	Do something based on the order, according to what you require...
	
	if ($order_meta_data['key'] ... ) {
		// Suppress this print job
		return false;
	}
	*/
	
	// If our conditions did not match, then leave things as they were
	return $proceed;

}

 

Alternatively, to suppress all automatic printing (so that printing is manual-only):

add_filter('woocommerce_print_orders_print_on_payment_complete', '__return_false');
add_filter('woocommerce_print_orders_print_order_upon_processed', '__return_false');

How can I automatically print when the order status changes?

The default setup of the plugin should print at the right time for the payment method type (e.g. for “manual” payment methods, like cash-on-delivery or cash-on-collection, it will print as soon as the order is placed; for electronic payments (e.g. PayPal, Stripe), it will print as soon as the order is paid). However, it may be that you have a need to print based on a customised order status change. Here is how to do so.

Create the directory wp-content/mu-plugins in your WP install, if it does not already exist.

In that directory, create a file named wp-content/mu-plugins/order-status-change.php, with these contents:

<?php
add_filter('woocommerce_order_status_changed', 'my_woocommerce_order_status_changed', 10, 3);
function my_woocommerce_order_status_changed($order_id, $old_status, $new_status) {
 if ('on-hold' == $old_status && 'processing' == $new_status) {
 global $woocommerce_ext_printorders;
 $woocommerce_ext_printorders->woocommerce_print_order_go($order_id);
 }
}

You should change the statuses in the above (on-hold, processing), to match your desire setup. Other available statuses in WooCommerce by default are: failed, completed, refunded.

If someone pays using a payment method (e.g. cash-on-delivery) which triggers an immediate print-out when the order is placed, you can suppress that with this fragment:

add_filter('woocommerce_print_orders_print_order_upon_processed', '__return_false');

Are orders created manually in the WooCommerce back-end automatically printed?

No. Manual orders are not automatically printed. If you want them to be printed, then you should press the button on the order page in the back-end as part of your process for manually creating them.

My checkout has slowed down. How can I perform printing in the background?

By default, the plugin prints orders during the customer’s placement of the order. i.e. Whilst WooCommerce is receiving the order and processing it, and generating the “Thank you” page for the browser, the sending of a print job to Google Cloud Print is one of the tasks carried out. Because this involves talking to the network, and generating a PDF to print, this can take a few seconds. The customer then spends a few more seconds looking at the spinning graphics on the checkout page.

If you prefer to instead have the print job performed in the background, then you can do that via this code fragment (add it to your functions.php, or as an mu-plugin):

add_filter('woocommerce_print_orders_via_cron', '__return_true');

With this tweak, instead of printing immediately, the plugin will instead schedule a task (for a few seconds ahead) in WordPress’s “scheduled task” system. WordPress will then call this task in the background. For this to work, WordPress’s scheduled task system needs to be working on your website. That is the reason why this option is not the default…. a very small percentage of WP installs have a broken task system (sometimes deliberately – e.g. Heart Internet in the UK for many years have turned it off for all their customers). To investigate the scheduled task lists in your system, you can use this free plugin: https://wordpress.org/plugins/wp-crontrol/. Please note that investigating your WP’s scheduled task system is not something we can do as part of our standard support.

I wish to filter the items printed, or change their order

This requires version 2.7.13 or later (August 2018) of the plugin.

The code sample below sorts order items by SKU. A competent PHP developer will easily be able to adapt this to fulfil other requirements (e.g. sort in a different way, or omit unwanted items). Please note that our general FAQ on customisations applies.

<?php

// This code sample is not compatible with WooCommerce 2.x
add_filter('woocommerce_printorders_print_order_items', 'my_woocommerce_printorders_print_order_items');
function my_woocommerce_printorders_print_order_items($order_items) {

  if (is_array($order_items)) {
    uasort($order_items, 'my_print_order_sorting_function');
  }

return $order_items;
}

// This function sorts based on SKU
function my_print_order_sorting_function($a, $b) {

  // Confirm that both items are order product items
  if (!is_a($a, 'WC_Order_Item_Product')) return is_a($b, 'WC_Order_Item_Product') ? 1 : 0;
  if (!is_a($b, 'WC_Order_Item_Product')) return -1;

  $product_a = $a->get_product();
  $product_b = $b->get_product();

  // Confirm that both products exist
  if (!is_a($product_a, 'WC_Product')) return is_a($product_b, 'WC_Product') ? 1 : 0;
  if (!is_a($product_b, 'WC_Product')) return -1;

  // In this example, we sort via SKU
  return strcmp($product_a->get_sku(), $product_b->get_sku());
}

I have a payment method for which I want to print as soon as an order is placed

With our WooCommerce automatic order printing plugin, for some payment methods (e.g. cash on collection, BACS transfer) it makes sense for the print-out to be done instantly on order creation, instead of (as for automated/electronic payment methods, e.g. PayPal, card payment) when payment has been made.

The plugin contains a default list of such payment methods. However, your WooCommerce store may have other payment methods added by other extensions that should also come into this category.

To do this, you can add the code below as an mu-plugin, or in your child theme’s functions.php, or as a snippet (whatever method you prefer for adding code to your site). You will need to change method_id for the true internal identifier of the new payment gateway. You can discover what this is by reading its code, or asking its supplier.

add_filter('woocommerce_print_orders_order_now', 'my_woocommerce_print_orders_order_now', 10, 3);
function my_woocommerce_print_orders_order_now($print_now, $payment_method, $order) {
return ('method_id' == $payment_method) ? true : $print_now;
}

If, after doing so, you get the infamous WordPres “white screen of death”, then you accidentally introduced a typing mistake somewhere, and should undo it.

Customisation and developer information and common usage issues

This plugin uses WordPress’s standard customisation mechanisms – hooks and filters. As with every other such plugin, a competent developer can read the plugin code, and hook into it at any of those points (see here, or here for a tutorial). (Please note that customised development is not included in the purchase price of this plugin).

To customise the output of your invoices/packing notes/etc., for all formats except the “internal” (short) format, you can follow the link on the WooCommerce -> Settings page, and use the options found in the dashboard there. You can also create your own templates for those options.

To customise the “internal” format’s template, you have various options. The output is created by the file templates/cloud-print.php found in the plugin’s directory (wp-content/plugins/woocommerce-printorders). You can copy this file as templates/cloud-print.php in your theme or child theme directory, and then modify it. Instructions are at the top of that file. If you simply wish to add or change CSS styles, then this can also be done with a hook. Alternatively, you can use the woocommerce_printorders_printtemplate filter to use a template of your own devising at a different location. There are various other hooks that may be better than copying the template, for simple tasks.

Thirdly, you may find the debugging log feature useful – this is configured in WooCommerce -> Settings. WooCommerce’s standard logging mechanism is also used, so you can also find logs in your WooCommerce log directory (usually wp-content/uploads/wc-logs).

I am using a customised template, and don’t know how to add a new font to the PDF?

In PDFs, standard Windows core fonts are available. Our plugin also adds Deja Vu, which has good UTF-8 coverage (which the Windows standard fonts don’t). But in case you want to import another font…

If you are printing the output of another plugin, then you will need to consult that plugin’s documentation for guidance on how to embed extra fonts into its output.

If using this plugin’s default template, then you can add extra fonts, like so:

  1. Log in to the shell on your webserver
  2. Navigate to the directory wp-content/plugins/woocommerce-printorders/gcpl/dompdf
  3. Copy the font you wish to import, which must be in TrueType format, into this directory. Include bold and italic versions, if you intend to use them.
  4. Run the script load_font.php in that directory (run “php load_font.php” to show the syntax). Make sure that the font name matches the font name you will use in your template HTML.

Remember to use the CSS font-family selector where appropriate in your template HTML to actually select your chosen font.

Note that the above changes will be wiped out if/when you upgrade the plugin. To avoid this, after adding the font, you can copy the fonts directory (wp-content/plugins/woocommerce-printorders/gcpl/dompdf/lib/fonts) to a different directory on your webserver, and define the constant DOMPDF_FONT_DIR in your wp-config.php to point to your new directory.

e.g. if you copied it to the folder /home/myuser/public_html/dompdf-fonts, then you’d put:

define(‘DOMPDF_FONT_DIR’, ‘/home/myuser/public_html/dompdf-fonts’);

My thermal printer is printing large vertical margins (i.e. blank sections) when I print through Google Cloud Print – how can I prevent this?

All users who have reported this issue also eventually found the same solution – they were connecting to Google Cloud Print via a Windows machine, and in the advanced printer options in Windows, they found settings for applying page margins. Changing/removing these settings removed the margins. Exactly what options your printer provides, and what it looks like, will vary between printers.

Alternatively, you may be able to resolve the issue by instructing the plugin to use a different paper size. To do this, edit the settings in WooCommmerce -> Settings -> General.

You may need to experiment with size to see what works for you – some users have found that there printer responds better at an apparently “wrong” size.

My thermal printer is printing fonts too small – how can I make them bigger?

Firstly, you can change the print-out template in any way you like, using the advice in the customisation paragraphs immediately preceding this section. If you just want to boost the font size, then you can also do this without tweaking your template at all, but just by using CSS. Go to “Settings -> Google Cloud Print” in your WordPress dashboard, and add this as the print header, and then remember to save your settings:

<style type="text/css">
html, body, p { font-size: 150%; }
</style>

You can test the effect of this by viewing any order (WooCommerce -> Orders -> (Order Page)) and pressing the button to send the order to Google Cloud Print. You can then adjust the “150%” above to a value that is appropriate for your printer.

Alternatively, it may be that your fonts are small because the printer driver is doing a “fit-to-width”, based on a wide paper size. You may be able to resolve the issue by instructing the plugin to use a different, smaller paper size. To do this, add this to your wp-config.php file, after the opening lines:

define('DOMPDF_DEFAULT_PAPER_SIZE', 'a5');

The above line will set the paper size to A5 (i.e. the ISO standard A5 paper size). You can use any of a0-a10, b0-b10, c0-c10, letter, and various other values (use lower case) – you may need to experiment to see what works for you.