• Resolved lencw

    (@lencw)


    The website I’m working on takes orders with no shipping, then the shipping evaluated when products are packed, this is due to a very varied product mix. So we need the invoice to be an order confirmation. I can remove the invoice number and date, but need to change the word “Invoice” for “Order confirmation”. I have achieved this with a small change to the invoice.php file. The issue is that I really don’t want a child theme, is there another way to do this without one? Where is the template getting the word “invoice” from, can that be changed with a php snippet?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @lencw:

    You can achieve this with a code snippet, as described in the documentation: Custom PDF filenames.

    For your specific case, you can use this code snippet:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Customize the invoice title
     */ 
    add_filter( 'wpo_wcpdf_invoice_title', function( $title, $document ) {
        $title = 'Order confirmation';
        return $title;
    }, 10, 2 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Alternatively, with the?Professional extension, you can do this right in the documents’ settings (it is available for all them):

    In the screenshot above, you can see that the invoice title, as well as the PDF filename pattern, have been updated to ‘Receipt’.
    Thread Starter lencw

    (@lencw)

    Thanks, that’s excellent, just the job and exactly how I wanted this to be solved. I use quite a lot of action/filters already, added using the Snippets plugin. Its finding the snippets that is the issue – thanks again. I will check out the professional plugin.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for confirming that it is what you wanted, @lencw ??

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and all the best with your store!

    Thread Starter lencw

    (@lencw)

    Yordan, yes will do.

    Further to this, during testing, realised that the file attachment on the customer email when they place the order is named “invoice-26685.pdf”, is there a way to change the file name from “invoice-” to something else with actions/filters?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Yes, there is! You can achieve it with this code snippet:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Customize the PDF invoice filename to 'order-confirmation-{$invoice_number}.pdf';
     */
    add_filter( 'wpo_wcpdf_filename', function( $filename, $template_type, $order_ids, $context ) {
        $invoice_string = _n( 'invoice', 'invoices', count( $order_ids ), 'woocommerce-pdf-invoices-packing-slips' );
        $new_prefix = _n( 'order-confirmation', 'order-confirmations', count( $order_ids ), 'woocommerce-pdf-invoices-packing-slips' );
        $new_filename = str_replace( $invoice_string, $new_prefix, $filename );
     
        return $new_filename;
    }, 10, 4 );
    Thread Starter lencw

    (@lencw)

    Yordan, thanks, that’s useful. I have already sorted this by buying your pro version for the website in question, can achieve both the above in the pro plugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change template without child theme’ is closed to new replies.