• Resolved yknivag

    (@yknivag)


    Hi,

    I would like to create a small snippet for my functions.php file that adds a note to the order when the admin prints the packing list (to be able to tell which are printed and which are yet to be).

    Looking through the examples in the plugin help page I wrote this based on the example for wf_pklist_alter_footer_data:

    function add_note_to_order_when_printing_packing_slip( $footer_data, $template_type, $order ) {
    	if( $template_type=='packinglist' ) {
    		$order->add_order_note( 'Packing List Printed', false );
    	}
    }
    add_filter( 'wf_pklist_alter_footer_data', 'add_note_to_order_when_printing_packing_slip', 10, 1 );

    However it doesn’t work as the filter wf_pklist_alter_footer_data passes only one variable to the function, not the three variables you show in your documntation.

    Is there any hook or filter that passes both the $template_type and the $order to the function?

    If I have both of those then I could achieve my goal.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @yknivag,

    Please go to General Settings > Help Guide > Filters to find the full list of filters present in the plugin.

    Thread Starter yknivag

    (@yknivag)

    Hi,

    That’s exactly what I did.

    I used this example from that page

    add_filter('wf_pklist_alter_footer_data', 'wt_pklist_alter_footer', 10, 1);
    function wt_pklist_alter_footer($footer_data,$template_type,$order)
    {
    $footer_data='Footer name';
    return $footer_data;
    }

    The example doesn’t work, it leads to a fatal error. The function has there arguments but it’s called with only one.

    Is the somewhere documentation that contains working examples?

    Plugin Author WebToffee

    (@webtoffee)

    Hi @yknivag,

    Please try using below code:

    add_filter( 'wf_pklist_alter_footer_data', 'webtoffee_pklist_alter_footer_data', 10, 3 );
    function webtoffee_pklist_alter_footer_data( $footer_data, $template_type, $order ) {
    	$footer_data = 'Footer name';
    	return $footer_data;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hook or Filter that exposes order id?’ is closed to new replies.