Add Billing Company to filename
-
Hello
I used the code from the documentation to change the filename of the invoice pdf and I wanted to add the billing_company. So I tried this code but it didn’t work. Any help would be great
// Change filenames of PDFInvoice Plugin add_filter( 'wpo_wcpdf_filename', 'wpo_wcpdf_custom_filename', 10, 4 ); function wpo_wcpdf_custom_filename( $filename, $template_type, $order_ids, $context ) { $count = count($order_ids); switch ($template_type) { case 'invoice': $name = 'angebot'; ; break; case 'packing-slip': $name = _n( 'packing-slip', 'packing-slips', $count, 'woocommerce-pdf-invoices-packing-slips' ); break; case 'proforma': $name = _n( 'proforma-invoice', 'proforma-invoices', $count, 'wpo_wcpdf_pro' ); break; case 'credit-note': $name = _n( 'credit-note', 'credit-notes', $count, 'wpo_wcpdf_pro' ); break; default: $name = $template_type; break; } if ( $count == 1 ) { $document = wcpdf_get_document( $template_type, $order_ids ); if ( $number = $document->get_number() ) { $suffix = $number; } elseif (isset($document->order) && method_exists($document->order, 'get_order_number')) { $number = $document->order->get_order_number(); } else { $number = $order_ids[0]; } $suffix = $number; } else { $suffix = date('Y-m-d'); // 2020-11-11 } $order = wc_get_order($order_ids); $filename = $name . '-' . $order->get_billing_company() . '-' . $suffix . '.pdf'; return $filename; }
thanks werner
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add Billing Company to filename’ is closed to new replies.