• Resolved dav74

    (@dav74)


    Hi there,

    Is there any way to only show the packing slip when the order is set to “confirmed” – ie when payment has been received? I saw this on another very good plugin, and it makes so much sense.

    When you have dozens of orders to print each day, the chance of printing a packing list by mistake for someone who has not paid (or even for a cancelled order) is very high. Then the risk of sending out goods to someone who has not paid becomes a serious problem. I really like your plugin so far, but this makes me think twice.

    When you have real experience of working in a warerhouse, allowing a packing list to be printed for an unpaid order is not very sensible. Maybe you would be willing to have a toggle option, to enable to only display the packing list button when an order is set to complete?

    Sending out wrong orders is one of the biggest worries small businesses have, where our shipping systems are not as bullet proof as larger businesses.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Currently not possible via the settings, but you can control the visibility of the button with a filter.
    You can adapt the invoice example here to do this for the packing slip: https://www.ads-software.com/support/topic/invoice-is-downloadable-on-any-order-status/

    Note that this does not affect the bulk export option.

    Hope that helps!

    Thread Starter dav74

    (@dav74)

    Well that is great news. Now comes the pretty smile part ??
    I’m rather useless at understanding these filters and working with them. Would you be able to adapt that filter on the other post for me, so that it applies just to “Packing Lists” and only within the admin section where you see the orders?

    If possible, would make my day! Thanks

    Plugin Contributor Ewout

    (@pomegranate)

    Sure, it’s a simple matter of replacing invoice with packing-slip!

    
    add_filter( 'wpo_wcpdf_listing_actions', 'wpo_wcpdf_disable_packing_slip', 20, 2 );
    add_filter( 'wpo_wcpdf_myaccount_actions', 'wpo_wcpdf_disable_packing_slip', 20, 2 );
    add_filter( 'wpo_wcpdf_meta_box_actions', 'wpo_wcpdf_disable_packing_slip', 20, 2 );
    function wpo_wcpdf_disable_packing_slip ( $actions, $order ) {
    	// make sure $order is the actual order object
    	$order = wc_get_order( $order );
    
    	// set allowed order statuses (slugs, so 'on-hold' instead of 'On Hold')
    	$allowed_statuses = array( 'completed','processing' );
    
    	// remove button/link status not allowed
    	if ( !in_array($order->get_status(), $allowed_statuses) ) {
    		unset( $actions['packing-slip'] );
    	}
    
    	return $actions;
    }
    

    This shows the packing slip button only for ‘processing’ and ‘completed’ orders.
    Ewout

    Thread Starter dav74

    (@dav74)

    Hi there,

    Firstly thank you for the quick reply. I get the following error with this snippet:

    The code snippet you are trying to save produced a fatal error on line 2:
    syntax error, unexpected ‘&’

    Secondly is there any way to make it that the packing list only appears for “complete orders” (ie not for “processing orders”).

    Thanks in advance

    Plugin Contributor Ewout

    (@pomegranate)

    That must be a a copy paste error, there’s no & in line 2 :)\

    Change this:

    
    $allowed_statuses = array( 'completed','processing' );
    

    to:

    
    $allowed_statuses = array( 'completed' );
    

    For only completed orders.

    Thread Starter dav74

    (@dav74)

    I’ve pasted the snippet below which I am using, but I am getting this error when I publish it: The code snippet you are trying to save produced a fatal error on line 2:
    syntax error, unexpected ‘&’

    // Change packing list icon
    add_filter( 'wpo_wcpdf_listing_actions', 'wpo_wcpdf_disable_packing_slip', 20, 2 );
    add_filter( 'wpo_wcpdf_myaccount_actions', 'wpo_wcpdf_disable_packing_slip', 20, 2 );
    add_filter( 'wpo_wcpdf_meta_box_actions', 'wpo_wcpdf_disable_packing_slip', 20, 2 );
    function wpo_wcpdf_disable_packing_slip ( $actions, $order ) {
    // make sure $order is the actual order object
    $order = wc_get_order( $order );

    // set allowed order statuses (slugs, so 'on-hold' instead of 'On Hold')
    $allowed_statuses = array( 'completed' );

    // remove button/link status not allowed
    if ( !in_array($order->get_status(), $allowed_statuses) ) {
    unset( $actions['packing-slip'] );
    }

    return $actions;
    }

    Plugin Contributor Ewout

    (@pomegranate)

    Must be a copy paste error somewhere! As you can see there is no ‘&’ in the code I posted. Neither does your code, but since you’re note posting it in a code block that’s hard to tell. Do you see an ampersand in the code in Code Snippets? If not, try pasting it in a text editor (Notepad for example) and then copy it from there again, this may get rid of some HTML you may be getting when copy pasting. Alternatively, try copy pasting it from here:
    https://pastebin.com/raw/5bt6TMTs

    Thread Starter dav74

    (@dav74)

    Excellent that worked. Well spotted with the copy and paste issue.
    Exactly what we required, so thanks again for the helpful support.

    Thread Starter dav74

    (@dav74)

    Hi there,

    I just installed your latest release and see that the snippet which hid the packing slip / invoice until an order was set to complete, now does not work. The packing slip / invoice icon does not display when the snippet is active. Here is the snippet we used. Would be grateful if you can help with a fix!

    add_filter( ‘wpo_wcpdf_listing_actions’, ‘wpo_wcpdf_disable_packing_slip’, 20, 2 );
    add_filter( ‘wpo_wcpdf_myaccount_actions’, ‘wpo_wcpdf_disable_packing_slip’, 20, 2 );
    add_filter( ‘wpo_wcpdf_meta_box_actions’, ‘wpo_wcpdf_disable_packing_slip’, 20, 2 );
    function wpo_wcpdf_disable_packing_slip ( $actions, $order ) {
    // make sure $order is the actual order object
    $order = wc_get_order( $order );

    // set allowed order statuses (slugs, so ‘on-hold’ instead of ‘On Hold’)
    $allowed_statuses = array( ‘completed’ );

    // remove button/link status not allowed
    if ( !in_array($order->get_status(), $allowed_statuses) ) {
    unset( $actions[‘packing-slip’] );
    }

    return $actions;
    }

    Thread Starter dav74

    (@dav74)

    UPDATE!!

    You can ignore that last message. I just unpublished the snipped and republished and all seems to work again ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Only show packing list when order “Confirmed”’ is closed to new replies.