Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Last active August 27, 2020 08:10
Show Gist options
  • Save hedqvist/155ae8a7dbae789a2b0ff840665e3b7d to your computer and use it in GitHub Desktop.
Save hedqvist/155ae8a7dbae789a2b0ff840665e3b7d to your computer and use it in GitHub Desktop.
Automatic Printing - Custom Printer ID
<?php
/**
* @snippet WooCommerce - Print to different printerID depending on shipment method
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.4.0
*/
function redlight_print_labels_to_customer_printer($printjob, $order) {
if( strpos($printjob['title'], 'Packingslip') !== false) {
return $printjob;
}
if( strpos($printjob['title'], 'Invoice') !== false) {
return $printjob;
}
if( 'Brev i posten' === $order->get_shipping_method() || 'Fri frakt' === $order->get_shipping_method() || 'Free delivery' === $order->get_shipping_method() || 'Postage' === $order->get_shipping_method() ){
$printjob['printerId'] = 69652734;
}
return $printjob;
}
add_filter('redlight_wc_automatic_printing_data', 'redlight_print_labels_to_customer_printer', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment