Home / Topic / WCMp PDF Invoice / Download delivery notes for the order and sub-orders in bulk in woocommerce
Download delivery notes for the order and sub-orders in bulk in woocommerce Resolved
In woocommerce orders.
How can we download all invoices and delivery notes in bulk (the main order and subcommands).
Currently when launching the bulk download of delivery notes or invoices this downloads only for the main order.
Help us to download the invoices and delivery notes of the order and its sub-orders in bulk because we manage several orders, we are obliged to open the main order to download the delivery notes and invoices of each sub-order.
It takes too long.
Thank you
Hi,
please add this code in the function.php of the current active theme :
add_action('init','wcmp_pdf_infoice_admin_end_modify');
function wcmp_pdf_infoice_admin_end_modify(){
global $WCMp_PDF_Invoices;
remove_filter('handle_bulk_actions-edit-shop_order', array($WCMp_PDF_Invoices->admin, 'pdf_invoice_packing_slip_bulk_action_handler'), 10, 3);
add_filter('handle_bulk_actions-edit-shop_order', 'pdf_invoice_packing_slip_bulk_action_handler', 10, 3);
}
/**
* handle PDF invoice & packing slip bulk action
*/
function pdf_invoice_packing_slip_bulk_action_handler($redirect_to, $doaction, $order_ids) {
global $WCMp_PDF_Invoices, $WCMp;
if (!array_key_exists($doaction, $WCMp_PDF_Invoices->admin->pdf_actions)){
return $redirect_to;
}
if (empty($order_ids)) {
return $redirect_to;
}
foreach ($order_ids as $order_id) {
$wcmp_suborders = get_wcmp_suborders( $order_id );
if($wcmp_suborders){
foreach($wcmp_suborders as $suborder ){
$suborder_ids[] = $suborder->get_id();
}
}
}
if($suborder_ids)
$order_ids = array_merge($order_ids,$suborder_ids);
$general_settings = get_wcmp_pdf_invoices_settings();
$args = array(
'order_ids' => $order_ids,
'user_id' => get_current_user_id(),
'user_type' => 'admin',
'settings' => $general_settings
);
$html = $WCMp_PDF_Invoices->utils->get_html($doaction, $args);
if ($html) {
$pdf_maker = get_wcmp_pdf_invoices_pdfmaker( $html, $general_settings );
$pdf = $pdf_maker->output();
wcmp_pdf_invoices_pdf_headers( $doaction.'.pdf', $general_settings['pdf_output'], $pdf );
echo $pdf;
die();
}
exit;
}
Copy
thank you for your help. problem fixed
When we download the invoices we want them to open in a new tab not on the same page of orders.
When we download the invoices we want them to open in a new tab not on the same page of orders.
There is another problem, when we add your code, that we try to download the invoices by opening the orders that would generate an error. Here is capture
Hi, Sorry for the delayed response, as somehow we missed this thread.
Please let us know if you are still facing the issue.
regards,
We have not received any update from you for a long. Hope this ticket is already been resolved.
We are now closing this ticket. Kindly create a new one if you need any further help.
The topic ‘Download delivery notes for the order and sub-orders in bulk in woocommerce’ is closed to new replies.