PrintNode automatic printing for WooCommerce – documentation

PrintNode for WooCommerce – Documentation index

Questions applying to all our commercial WordPress plugins

How long do you provide access to new plugin releases and support for?

All plugin purchases come with included access to support and access to downloads for 12 months. After 12 months, you can renew access if you want to.

If you do not want to renew, then your existing plugin will not be de-installed or de-activated or changed in any other way. Of course, we cannot guarantee what level of compatibility it will have with future releases of WordPress or (if relevant) WooCommerce.

Do you have a trial version of your plugins available / what is your refund policy?

We do not have trial versions of our plugins available, or refund trial purchases. However, we are committed to providing support for any technical issues you have with any of our plugins, and all plugins include 12 months of support. If the plugin does not do what the product description says it does, then you can have a refund (this should be requested within 10 days of purchase), subject to allowing us to investigate the problem.

This policy specifically excludes third-party failures; for example, if a plugin depends upon a third-party service which malfunctions or closes down, you will not be eligible for any refund for the plugin purchase. It also explicitly excludes failed attempts by the customer to implement PHP code customisations to the plugin, and faults in third-party code. Refunds are not offered for “speculative” purchases where the customer is hoping that the software can do something which is not advertised; plugins are priced cheaply and you should check your requirements before purchase. This policy allows us to keep prices down for our customers (i.e. means they don’t subsidise the support and non-refundable-to-us transaction fees for speculative purchases that get refunded).

For EU customers, your right to a refund of digital goods that you have not requested a download of remain intact. You can request a refund of goods that have not yet been downloaded for up to 14 days after purchase. These requests will be verified using our download logs.

How can I download a PDF invoice/receipt for my purchase?

You can download a PDF invoice/receipt for plugins purchases from your account page, here.

How many licences should I buy?

You will need a separate licence for each individual WordPress installation which you wish to receive plugin updates (i.e. future releases), or to request support for.

A WordPress Network is a single installation of WordPress, so only requires one licence, regardless of how many blogs you have on the network.

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.

Can you write some code for me, to customise the plugin?

Plugin purchase prices do not include hand-written code, even if it is only a few lines.

At commodity prices, and including 12 months of updates to new versions (including compatibility with future releases of WordPress and (where relevant) WooCommerce), and personal support, the margins when selling plugins are small. As a result, plugin sellers rely upon selling to many customers – and personal customisations are not economic (even if potentially useful for other customers).

You are, of course, welcome to send in ideas for new features. If you need a developer to customise for you, though, then we suggest Codeable – https://codeable.io – where there is a large marketplace of WordPress and WooCommerce experts offering their services.

Where can I download my plugin purchase?

After purchasing one of our WordPress plugins, you can download from any of three or four places:

  1. The “thank you” page in your web browser, that appears immediately after completing payment.
  2. From your Simba account, here.
  3. Using the link in your order confirmation email.
  4. If you have already installed and begun using the plugin, you can obtain updates (when available) from the “Plugins” page in your WordPress dashboard.

How do I install my plugin?

If you’ve purchased one of our WordPress plugins, then thank you! Here’s how to install…

1. Go to the “Plugins” page in your WordPress dashboard, and press “Add New”

Add a new plugin

2. Press the “Upload Plugin” button

Upload a plugin

3. Press the button to select a zip file. Select the zip file for your plugin. Then press “Install Now”.

Uploading the zip file

4. When the plugin has uploaded, press the “Activate” button.
Activate

N.B. If you have the free version of any of our plugins (e.g. WooCommerce EU VAT Compliance, or Two Factor Authentication), then you should also de-activate and de-install the free version. Your settings will be retained by the paid version. It does not matter whether you de-activate and de-install before, or after, installing the paid version.

When buying a plugin, what is the difference between manual or automatic renewal?

All our plugins come with included access to personal support and updates (new versions of the software) for 12 months (more information). After this 12 months, you can keep on using the software, without any restrictions. However, if you want to renew, you can either do so manually (i.e. come back to the shop and make a fresh purchase) or automatically (i.e. an order will automatically be created and emailed to you, and payment taken if you have a payment method on your account). We offer a discount to those who choose automatic renewal. You can cancel a subscription at any time (yes, even 5 minutes after you purchased it).

Where can I see the plugin changelog?

For a plugin that you have purchased, the changelog is in the file “readme.txt” in the plugin zip.

For our current on-sale version (i.e. the latest version), you can see the changelog by going to the shop, and then going to the product page, and then clicking the link “Plugin changelog” from the left-hand side of the page.

How do I change which site is using a licence?

If you wish to stop using one of your plugin licences on one site, and instead use it on another, then do this:

1. Disconnect the “old” site.

Go to the “Plugins” page in the WordPress dashboard, and find the plugin’s entry. Press the “Disconnect” button.

Disconnecting

2. Connect the “new” site.

Go to the “Plugins” page in the WordPress dashboard on the new site, and connect.

Connecting

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 account with us, then please go here).

Is this plugin still supported and maintained?

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


WooCommerce Automatic Order Printing (PrintNode)

What is PrintNode and how do I use it?

PrintNode (printnode.com) is a service for connecting your printers to the Internet, bringing a range of benefit such as the ability to print directly from a website and not being hindered by firewalls. This plugin uses PrintNode to automatically print new WooCommerce orders. You can begin using PrintNode for free by signing up at their website.

To use PrintNode, you need a printer and a computer that it is attached to (which can be almost anything – including Windows, Mac, Linux, Raspberry PI). Just sign up for an account at their website, install their software on your computer, test it out, obtain your API key, and add it to the settings of our plugin.

What is the status of this plugin?

The code in this plugin is actively used and relied upon by many businesses across the world. It began life in the middle of 2013 (used on a take-away site running on WordPress 3.5 and WooCommerce 2.0, via Google Cloud Print). It has been continuously maintained and updated since then, being completely audited and re-engineered to work with PrintNode beginning in 2020. Since the first launch its code has been purchased for use with over a thousand live shops, running on all subsequent WordPress and WooCommerce versions.

How do I install this plugin?

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-printnode”. 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.

Is this plugin compatible with WooCommerce HPOS (high performance order storage) ?

Yes, releases from May 2023 onwards have added full support for WooCommerce high performance order storage (also known as custom order tables).

How do I configure and use this plugin?

There are three things to do to being using this plugin, beyond installing and activating it:

  • Firstly, you need to set up your printer with PrintNode. You will need to a) open an account with them, on a free or paid plan, b) Download and install their software on the computer that is driving your printer, and test printing successfully through it from your account. To learn about how to do this, go to the PrintNode website. Come back to this documentation once you have successfully printed a test page to your printer from your account on the PrintNode website.
  • Secondly, you need to connect your website to PrintNode. In your WordPress dashboard, go to the WooCommerce -> PrintNode -> Settings page. Enter your PrintNode API key by following the instructions, and then save your settings. Then choose which printers you want to use in WooCommerce -> PrintNode -> Printers, and save your settings there also.
  • Thirdly, you need to choose which print-outs to send to PrintNode when an order is completed. This is done in your WordPress dashboard, in the WooCommerce -> PrintNode -> 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).

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

We do not have a particular recommended printer. PrintNode is designed to be compatible with any printer at all, because it is ultimately itself just a transport, getting a print job across the Internet, past firewalls, to your existing printer setup. It is unfortunately not economic for us to invest in testing different printers, given the pricing expectations of the WooCommerce extensions market.

If you already possess your printer, then note that (at the time of writing this FAQ at least), PrintNode offer 1 month of free service. You can simply sign up for a free account, and test it directly.

So, any printer at all that you can connect to your computer and print from 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, and narrow-width printers (the plugin includes a simple template that can be used at any width).

We first tested and developed the first version of this 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 that causes a problem, 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 by WP Overnight (options set in these plugins for your print-out layout will be honoured), WooCommerce Delivery Notes, WooCommerce Product Add-Ons from woocommerce.com (it displays the customer’s chosen choices in the print-out), and WooCommerce Currency Switcher by Aelia (the print-outs will use the proper currency symbols).

How can I test whether PrintNode will work for me?

PrintNode have a free service-level offering. Go to their website, sign up for an account and then you can download their software to your computers and test it with your printers. You can test sending documents through PrintNode by uploading them within your PrintNode account on their website. If all is set up and working, then they should then print. If so, then this means that your printer is connected to PrintNode.

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

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

add_filter('woocommerce_printorders_printnode_print_order_items', function ($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());
}

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.

How can I automatically print when the order status changes?

This can be controlled in the plugin settings. You can print either upon payment events, or upon order status events (these things can overlap, of course – you most likely won’t want to print upon both; the screenshot below is only illustrative):

Printing upon an order status change

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 WooCommerce -> PrintNode -> Settings:

Configure copies per-printer

If you want to filter orders in a more complicated way, so that orders go to a printer only sometimes (depending on something to do with the order itself) 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 codeable.io or 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 contribute 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 woocommerce_printorders_printnode_copies filter. Using the passed parameters, 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('woocommerce_printorders_printnode_copies', function ($copies, $order, $printer_id, $source, $source_info, $printers) {

	// Get the order details
	$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 (print no copies)
		return 0;
	}
	*/
	
	// If our conditions did not match, then leave things as they were
	return $copies;

}, 10, 6);

 

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

add_filter('woocommerce_printorders_printnode_print_on_payment_complete', '__return_false');
add_filter('woocommerce_printorders_printnode_print_order_now', '__return_false');

 

I am trying to print in a language or using characters that are not appearing correctly – what can I do?

If the characters you are trying to print are part of standard PDF fonts, then you may need to switch the PDF engine from the default (“DomPDF”) to a different engine which has support for a wider range of languages (“mPDF”). To do this, additionally install and activate one of these plugins:

If this does not work, then likely you are using a font that is not part of the PDF standard. You should either a) switch to one of the standard fonts or b) follow this FAQ to embed your font.

I am using a customised template – how can I add a new font to the PDF?

This FAQ refers to the plugin’s built in “simple” template. If using a PDF generated by another plugin (e.g. WP Overnight’s PDF Invoices and Packing Slips), then you need to follow their documentation instead.

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-printnode/vendor/dompdf/dompdf/lib/fonts
  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. Navigate to the base directory of the plugin, and run the script load_font.php in the “utils” directory  (run “php utils/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-printnode/vendor/dompdf/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’);

What extra information about a product will be included in the print-out?

WooCommerce has a standard mechanism for adding “meta” information to a product, and our built-in simple template will include this information. This is the same extra information as you see in WooCommerce’s built-in order notification emails. So, as long as whatever plugin or code it is that allows/records extra information for a product is using this mechanism, it will be included.

If your print-outs are being generated by a third-party plugin (e.g. “WooCommerce PDF Packing Slips and Invoices), then you will have to refer to that plugin’s documentation to see, but generally they will also be including this information in the same way, since shop owners almost always want to see this information and hence an order summary excluding it would be of limited of use. (Of course, you can also look at the PDFs being generated by the plugin, and seeing what is in them).

For further customisations to the output, please see this FAQ.

How can I customise this plugin (including the document printed), beyond the obvious settings?

To customise the output of your invoices/packing notes/etc., for all formats except the “internal” (short) format, you should follow the link (from the WooCommerce -> PrintNode page, in the ‘Settings’ tab) to the settings for the plugin that creates the document, and use the options provided there. You can also create your own templates for those options (guided by the documentation for the relevant plugin). If you are using “PDF Invoicing and Packing Slips” by WP Overnight (which is our recommended partner plugin), then their documentation is available here.

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-printnode). 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 (the woocommerce_printorders_css filter). Alternatively, you can use the woocommerce_printorders_printnode_print_template 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.

For customising other aspects of its behaviour, 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 any plugins).

Finally, you may find the debugging log feature useful – this is configured in WooCommerce -> PrintNode -> 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 haven’t managed to connect my printer to PrintNode. Please can you help?

Unfortunately, the price we have pitched the plugin at does not allow us to help with any general printing issues. The plugin is a connector between PrintNode 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 after-sales support 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 PrintNode are all working, as pre-requisites. You can and should ask PrintNode for support with any issues with your PrintNode account and the associated service.

I wish to print when an order is placed, not when it is paid (or vice-versa)

This can be controlled in the plugin settings:

Settings for when to print

N.B. In  WordPress/WooCommerce developer terms, this means “when the woocommerce_checkout_order_processed action is called, rather than the woocommerce_payment_complete action.”.

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. Note that “when payment is made” does not mean the same as “when the order status changes” (technically, it is when WooCommerce fires the internal action woocommerce_payment_complete). Often when people are testing they do not realise this and expect something to print if they manually manipulate order status. (If you do want to always print when order status changes, go here for help).

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

Is your printer yet connected to PrintNode? This plugin sends a print job to PrintNode… until your printer is actually connected to PrintNode, it won’t print anything. Use the “Print” button in your PrintNode account – https://app.printnode.com/app/print – to send test print jobs to your printer via PrintNode. (Please note that for support for issues with PrintNode itself or your account with them, you should go to PrintNode).

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

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 PrintNode has received your job: https://app.printnode.com/app/print. If the job is in your PrintNode queue, then this plugin has finished its work – the problem lies further down the line, and you need to look at where.

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

Email debugging

What code can I use to trigger a print-out from a PHP context?

The code fragment below should work:

<?php
global $woocommerce_simba_printorders_printnode;
$woocommerce_simba_printorders_printnode->woocommerce_print_order_go($order_id);

This will print using your default settings. If there is some other action generated by some other component you use which you want to print on, then of course you can hook that action:

<?php
add_action('some_wordpress_action', function($order_id) {
global $woocommerce_simba_printorders_printnode;
$woocommerce_simba_printorders_printnode->woocommerce_print_order_go($order_id);
});

Print-outs through PrintNode have unwanted blank space at the bottom, middle or top of my print-out. What can I do about this?

We have heard from a few users who, generally using “continuous paper” printers, get more blank space after each print-out than they want. What can be done about this? Here are some things to look at:

1. Is the unwanted space inside the document that is being printed?

PrintNode is a service which receives a PDF file from another source (in the case of our plugin, from your website), and sends it to your printer. So, one possibility is that the PDF file itself has lots of blank space within it.

To investigate this, go to your WordPress dashboard, and to the page for the particular order you are looking at (WooCommerce -> Orders -> (Specific order). In the PrintNode meta-box, you can download the PDF file that is being generated, and look at it:

Getting the PDF

If, at the bottom of your document, there is lots of unwanted white-space, this might be just because you have to use a standard page size, and the order was a very short one, and there’s not much to do about it there. But, if your page size is much longer than your typical order, you could consider shortening it.

If the PDF is generating by another plugin, you will need to follow the documentation in that other plugin (and/or ask its providers for support) to achieve that. For example, for “WooCommerce PDF Invoices & Packing Slips”, their documentation is here. If you are using the “Simple summary” template provided within our plugin, then the settings for that, including generated page sizes, are withing WooCommerce -> PrintNode -> Settings:

Simple summary settings

2. Do you need to change the page size in your printer settings?

As well as the page size within the PDF document being sent to PrintNode, there is also the page size setting used in the printer driver itself. PrintNode clients (such as our plugin) do not directly communicate with the printer, but they are able to set a setting when sending the job to PrintNode. This setting is to choose a list of page sizes from the list advertised by PrintNode for each particular printer. In WooCommerce -> PrintNode -> Printers in your WordPress dashboard, you can choose your page size. So, you should look at that setting, and perhaps experiment with different possibilities there to see what works best. If you choose “Leave to printer driver”, then the plugin will not send any request for any particular page size; PrintNode and your computer/printer driver will handle it themselves. But if you make another choice, then this request will be passed on to PrintNode:

Choosing a paper size

 

3. Look at PrintNode’s FAQs / ask PrintNode for advice

In PrintNode’s FAQs – https://www.printnode.com/en/faq – there is a question “My PDF is printed correctly by Adobe Reader / Chrome / system tools, but with PrintNode it is rotated / the wrong size. What can I do?”, which you may wish to consult.

Beyond this, you could try printing the PDF (from step 1.) directly using PrintNode’s web app at https://app.printnode.com/app/print. Do you have the same problem? If so, then you should ask PrintNode for advice. In this situation, the extra margin is not coming from the plugin, but is between PrintNode and your printer. As such, there’s likely nothing you can change in the plugin to get a different result, so you will need to call upon the support that is available through your PrintNode account.

PrintNode support have told me to add specific “job options” – how can I do this?

To do this, you will need to use a WordPress filter:

  1. Create (if it does not already exist) the folder mu-plugins inside your wp-content folder, i.e. wp-content/mu-plugins
  2. In that folder, create a file with a name ending in .php – e.g. printnode-options.php
  3. Put content like this in the file:<?php
    add_filter('woocommerce_printorders_printnode_printing_job_options', function($options, $printer_id, $document_type, $printer_id, $title) {
    $options['job_options']['rotate'] = 180;
    return $options;
    }, 10, 5);

In the above example, we have set the “rotate” option to a value of 180. PrintNode’s documentation on supported job options is available here: https://www.printnode.com/en/docs/api/curl#printjob-options. Please note that customisations of this sort are outside of the scope of our standard support; we provide this documentation as a courtesy for those whom PrintNode support have advised to set specific options, and ask that you continue to work through that with them. The above is the mechanism for setting job options, but we cannot advise you as to whether they will achieve what you hope for or not, as that is beyond our control.

N.B. If after saving the above file your WordPress website crashes with the “white screen of death”, then you introduced a syntax error; you can bring your site back up by emptying or deleting the file, and trying again.

How can I reduce any printing delays in the WordPress scheduled task system?

Some of the content of this article is more technical; it is not necessary to understand it unless you have a specific problem you are trying to solve. If you are unsure of something, then your web hosting company are the best people to help you with any particular technical advice in this article.

When a print job is created, it is registered in WordPress’s scheduled task system (known as “WP Cron”), with a time of “now”.

Though this usually means that the task runs within seconds, it does not guarantee that it will run instantly, because WordPress runs its scheduled tasks on a “best effort” basis. The list is consulted when new pages are visited (so if your site has few visitors, this may not be instant), and there may be others ahead in the queue. Some web hosting companies also degrade the WP Cron system based on a mistaken belief (unfortunately promoted in some articles by bloggers) that it has a performance impact. (The writer of this article has extensively reviewed and made minor contributions to improve WordPress Cron code, so claims to know it much better than bloggers passing on hear-say!). Also, some site owners disable the WP Cron system (usually for mistaken reasons) and replace it with a system of only calling it every few minutes, which makes it much less responsive. (If you have done this, you are strongly advised to reverse it).

Eliminating the WP scheduler

If you wish to cut out the WP Cron system entirely, and send the print job directly at the checkout, then you can do so with these steps. Note that printing from the foreground in this way can mean the customer sees spinning icons for a few more seconds as the print job is prepared and sent. (This is why by default it is instead printed in the background using the scheduler).

To do this, you will need to use a WordPress filter:

  1. Create (if it does not already exist) the folder mu-plugins inside your wp-content folder, i.e. wp-content/mu-plugins
  2. In that folder, create a file with a name ending in .php – e.g. printnode-customisations.php
  3. Put content like this in the file:
    <?php
    add_filter('woocommerce_printorders_printnode_via_cron', '__return_false');

Trouble-shooting the WP scheduler

If you want to use the WordPress scheduler, but print jobs go into it and don’t come out (or come out only very slowly), then here are some items to look at.

1. Maintenance mode?

Firstly: is your website in maintenance mode? This disables scheduled tasks of all kinds – so turn it off first.

2. No visitors?

WordPress’s scheduler relies on the site having visitors. No visitors means that WordPress doesn’t run, and therefore can’t hand over to the scheduled task. If your site is in development, and you schedule a backup run for a time when all the developers are asleep, then that may be the cause for the scheduled task not running.

3. Is your scheduler explicitly disabled?

Perhaps your site has WordPress’s scheduler disabled in the configuration. You would normally know if you have done this, though perhaps someone else has worked on your site. To check manually, look for a line like this in your wp-config.php file (which is found in the root directory of your WordPress install), and remove it (or change true to false, making sure there are no quote marks around false):

define('DISABLE_WP_CRON', true);

In this case, the disabling may be something your web hosting company did intentionally, so be aware that they may re-disable it. Or, it may be something that you did intentionally, and you may have set another means of calling WordPress’s scheduler system, perhaps via your web hosting company’s control panel. In that case, the message about DISABLE_WP_CRON is to be expected – but note that it is then your responsibility to make sure that the scheduler is called frequently enough to process all the jobs scheduled on your site.

Also – note that it’s possible for DISABLE_WP_CRON to be set in a file other than wp-config.php; wp-config.php is simply the most likely (99%) place. If you have a warning about DISABLE_WP_CRON, but it is not found in wp-config.php, then it will be somewhere else – you will need to hunt for it.

A convenient way to see if scheduled tasks are running is to install the free plugin “WP Crontrol”. After installing it, in the “Tools” sub-menu of your WP admin dashboard there is an entry allowing you to see registered tasks, and the times they should run out. You can use that to see if you have any overdue ones.

4. Loopback connections are not working?

Some web hosting providers (one big one: Heart Internet) purposefully (though for no good reason) disable the “loop-back” connects that allows WordPress to run its scheduler. This is also the case if your website is password-protected. If loopback connections are not working (whether deliberately disabled or not), you can try this use WordPress’s alternative scheduling system – instructions here. The instructions amount to one thing: add a line anywhere in the middle of your wp-config.php file as follows (don’t add it too late in the file, or it will take no effect):

define('ALTERNATE_WP_CRON', true);

5. Try adding a cron job

If your web hosting company gives you “shell” access and you can set up cron jobs, and if you are confident/skilled enough to use that, then that’s a great solution. Jobs run that way won’t face any time-out issues imposed by the webserver. Read more about running via the shell here.

You could also schedule external automated calls to the scheduler by using a service such as EasyCron – see: https://www.easycron.com/cron-job-tutorials/how-to-set-up-cron-job-for-wordpress

6. Is your entire website password-protected?

Another cause is if your entire website is password-protected at the HTTP level (e.g. via a .htaccess file). This also prevents WordPress’s scheduler from working. You should configure your webserver to allow “loop-back” connections (i.e. connections to self), otherwise you WordPress scheduler and everything that depends upon it will be broken. If you are using Apache and .htaccess, then adding these two lines to the access control section of your .htaccess should work – after replacing a.b.c.d with your website’s IP address):

Allow from a.b.c.d
Satisfy Any

Please note: The above suggestion is just a suggestion. .htaccess configuration can get quite complicated. If you are not sure of the correct instructions for your particular server, then you may need to consult with either your web-hosting company or your local expert.

7. Still no good?

If the scheduler’s brokenness remains and is not caused by one of the above reasons, then the problem is likely with your web hosting provider. If the alternative scheduler also fails, then you need to either contact your web hosting company for support (ask them if loopback connections work, and if not, if they can enable them).