Adding custom config to Printus job data

It’s possible to filter and change the data that Printus sends to the PrintNode API for a print job. In the example below we’re adding some custom print options to the printjob before sending it to PrintNode.

You can learn more about the printjob configuration here.

function sl_cc_printus_add_custom_print_config($job_data){
	$job_data['options'] = array(
		'fit_to_page' => 'false',
		'rotate'      => 0,
	);
	return $job_data;
}
add_filter('printus__printnode_job_data', 'sl_cc_printus_add_custom_print_config', 10, 1);

In the above example we’re adding a key called options and then further adding some array items to that options key. The $job_data variable itself is an array with the following structure:

$job_data = array(
			'order_id'    => $order_id,
			'printerId'   => $printer_id,
			'contentType' => 'pdf_base64',
			'content'     => $content,
			'title'       => __( 'Order', 'printus-cloud-printing-for-woocommerce' ) . ' #' . $order_id . ' - Printus.cloud',
			'source'      => 'printus',
		);

This means to change the Printer ID that the print would be sent to, you can add the following snippet to your website:

function sl_cc_printus_change_printer_id($job_data){
  // ...
  // ...
  // You can add logic that would determine the Printer ID to use here.
  // ...
  // ...
  
	$job_data['printerId'] = 1234567 // Printer ID
	return $job_data;
}
add_filter('printus__printnode_job_data', 'sl_cc_printus_change_printer_id', 10, 1);
Scroll to Top