Avoid increase of invoice number on incomplete orders
-
HI, I’m using free version of WooCommerce PDF Invoices & Packing Slips.
I set up invoice pdf for attaching invoice only on “customer comleted order” email.
I want that invoice number is assigned only for orders that are in a completed status.
I used this snippet I found on this forum:add_filter( ‘wpo_wcpdf_listing_actions’, ‘wpo_wcpdf_disable_invoice’, 20, 2 );
add_filter( ‘wpo_wcpdf_myaccount_actions’, ‘wpo_wcpdf_disable_invoice’, 20, 2 );
add_filter( ‘wpo_wcpdf_meta_box_actions’, ‘wpo_wcpdf_disable_invoice’, 20, 2 );
function wpo_wcpdf_disable_invoice ( $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[‘invoice’] );
}return $actions;
}
It hides the button for generate invoice pdf, so I can avoid that someone assign invoice number on “payment waiting” order, but if I select all orders and use bulk action to export invoice pdf it assigns an invoice number even to incomplete orders.
Can I use some filter to export invoice pdf only for completed orders?
Moreover, if I open order detail admin page, I also see the “set invoice number and date” button.
How can I hide this button?
I have installed only woocomerce and WooCommerce PDF Invoices & Packing Slips.
Can you help me?
- The topic ‘Avoid increase of invoice number on incomplete orders’ is closed to new replies.