Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @nflor,

    As mentioned in the documentation the easiest way would be with our Professional extension. This will let you change the filename right in the plugin settings using the {{order_number}} placeholder.

    Having said that the second example code snippet can be slightly adjusted to give you the desired result:

    add_filter( 'wpo_wcpdf_filename', 'wpo_wcpdf_custom_filename_including_order_number', 10, 4 );
    function wpo_wcpdf_custom_filename_including_order_number( $filename, $template_type, $order_ids, $context ) {
    	$invoice_string = _n( 'invoice', 'invoices', count( $order_ids ), 'woocommerce-pdf-invoices-packing-slips' );
    	$new_prefix = _n( 'business', 'businesses', count( $order_ids ), 'woocommerce-pdf-invoices-packing-slips' );
    	$new_filename = count( $order_ids ) > 1 ? str_replace( $invoice_string, $new_prefix, $filename ) : sprintf( '%s-%s', $new_prefix, $order_ids[0] );
    	return $new_filename;
    }
    Thread Starter nflor

    (@nflor)

    Hi @kluver

    thank you so much for your help. I am really sorry to be so late in replying, but I had to fix a compatiblity issue using your plugin together with Order Signature for WooCommerce plugin, which supports you officially.
    Basically with your code I managed to download correctly the PDF with corrent new filename but I found a bug in email attachments, where the PDF extension disappeared. S a file was enclosed but without extension.
    I managed to fix typing %s-%s.pdf instead of simple %s-%s in the $new_filename variable.

    Thanks again,
    nflor

    • This reply was modified 3 years, 10 months ago by nflor.

    Hi guys!
    Sorry to butt in here; is there anything we can help with re. the Order Signature for WooCommerce side of things?
    Thank you!

    Thread Starter nflor

    (@nflor)

    Hi @wordpressheroes ,

    everything works now ??

    Thank you too!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom PDF filename’ is closed to new replies.