• Hey there,

    is there any possibility to get the formatted Invoice number into the filename?

    I’ve tried:

    add_filter( 'wpo_wcpdf_filename', 'wpo_wcpdf_custom_filename', 20, 4 );
    function wpo_wcpdf_custom_filename( $filename, $template_type, $order_ids, $context ) {
    	global $wpo_wcpdf;
    
    	switch ($template_type) {
    		case 'invoice':
    			$count = $wpo_wcpdf->export->set_invoice_number( $order_id );
    			$name = _n( 'Invoice_', 'Invoice_', $count, 'wpo_wcpdf' );
    			$company = $wpo_wcpdf->export->order->shipping_company;
    			$city = $wpo_wcpdf->export->order->shipping_city;
    			$number = $wpo_wcpdf->export->get_display_number( $order_ids[0] );
    			break;
    		default:
    			$name = $template_type;
    			$company = $wpo_wcpdf->export->order->shipping_company;
    			$city = $wpo_wcpdf->export->order->shipping_city;
    			$number = $wpo_wcpdf->export->order->get_order_number();
    			break;
    	}
    
    	if ( $count == 1 ) {
    		$suffix = $number . '-' . $company .  $city;
    	} else {
    		$suffix = date('Y-m-d'); // 2020-11-11
    	}
    
    	$filename = $name . '-' . $suffix . '.pdf';
    
    	return $filename;
    }

    but the Invoice number won’t shown up. Any ideas? Thx in advance!

    https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    Something else must be at play here, because by default the filename already contains the formatted invoice number. What are you getting? Have you enabled the ‘Use built-in sequential invoice number’ option in the settings?

    Ewout

Viewing 1 replies (of 1 total)

The topic ‘Invoice Number in Filename’ is closed to new replies.