View Categories

How to set a custom print trigger

You can set a custom hook to fire print jobs whenever that hook is called. This hook must pass the order_id or order object in it’s first argument so that Printus can get the order details to print.

When using the below snippet, Printus will always fire on that hook regardless of what you have selected on the Printus settings page.

The below snippet will send the print job before an order is set as complete. This snippet is solely for example purposes.

function sl_cc_printus_set_custom_print_trigger($hook){
	return 'woocommerce_pre_payment_complete';
}
add_filter('printus_settings__print_trigger_hook', 'sl_cc_printus_set_custom_print_trigger', 10, 1);

You can also return an array of hooks if you want Printus to fire on multiple hooks. The below snippet will print on both Order Process and Order on Hold statuses.

function sl_cc_printus_set_custom_print_triggers($hook){
	return array(
			'woocommerce_order_status_processing',
			'woocommerce_order_status_on-hold',
		);
}
add_filter('printus_settings__print_trigger_hook', 'sl_cc_printus_set_custom_print_triggers', 10, 1);
Scroll to Top