• Resolved petfresh

    (@petfresh)


    Hi,
    Could you please help me with attempting to get the status of a order ie. Printed/Not Printed.

    Currently, the plugin shows a tick next to the order but is it possible for me to add an order note with a snippet in the following form:

    // Update order note by packing slip creation 
    add_action('order_printed', function ($order_id) {
       if(packing_slip_status == 'true'){
    		$order = new WC_Order($order_id);
    		$date = new DateTime();
    		$note = __("The Order was printed on: $date");
    		$order->add_order_note( $note );
       }
    } ); 
Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    There are several hooks you could use for this: wpo_wcpdf_created_manually (for manual prints from the admin or my account) or wpo_wcpdf_email_attachment (for attachments).

    Unfortunately the manual action doesn’t receive the order ID, but there’s a third one (catch-all) that you could use: wpo_wcpdf_pdf_created. With that hook your code would look like this:

    
    // Update order note by packing slip creation 
    add_action('wpo_wcpdf_pdf_created', function ( $pdf, $document ) {
    	if( $document->get_type() == 'packing-slip'){
    		$date = new DateTime();
    		$note = __("The Order was printed on: $date");
    		$document->order->add_order_note( $note );
    	}
    }, 10, 2 );
    

    (untested, but I’m sure you’ll manage with the above information)

Viewing 1 replies (of 1 total)

The topic ‘Get Status on Print’ is closed to new replies.