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');

Posted in: WooCommerce Google Cloud Print Automatic Printing