• Resolved Iamhere

    (@iamhere)


    Hey there

    What’s the best way to add some custom text to the PDF invoice based on the payment method.

    Would it be best to do this through copying the template to a child theme, or could a function snippet filter hook work OK? Just wondering the best method to interact with your plugin.

    I want to simply show bank account number if a user selects the bank transfer payment option – but this is a conditional as there’s no point in showing it on the credit card PDF invoice!

    Thank you

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

    (@dwpriv)

    You can use one of our action filters here to create your code snippet.

    Thread Starter Iamhere

    (@iamhere)

    @dwpriv thank you very much for that helpful hint.

    Another query, is there a way to print the invoice download link on the “order-received” thank you page after checkout? I can see the invoice is available on the order page – but how to include on the thank you page?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thread Starter Iamhere

    (@iamhere)

    Thank you so much for your help.

    Another query in the same thread: How to change the document title, based on the payment status:

    I can see from here, that we can access the document title, but I have tried to combine that with a query about the order payment status and I can’t get it to work. Basically, need to change the title to “RECEIPT” if the payment status is paid.

    /**
    * Change the invoice title to 'Receipt'
    */
    add_filter( 'wpo_wcpdf_invoice_title', 'wpo_wcpdf_invoice_title', 10, 3 );
    function wpo_wcpdf_invoice_title ( $title, $document, $order ) {

    if ( $order->is_paid() ) {
    $title = 'GST Receipt';
    return $title;
    }

    }

    returns error: Fatal error: Too few arguments to function wpo_wcpdf_invoice_title(), 2 passed – I’m guessing order object not available in this filter, so how to do the above?

    • This reply was modified 5 months, 2 weeks ago by Iamhere.
    Thread Starter Iamhere

    (@iamhere)

    Never mind I solved it and posting here for anyone who might need it:


    /**
    * PDF Invoices & Packing Slips for WooCommerce:
    * Change title based on payment method
    */
    add_filter( 'wpo_wcpdf_invoice_title', function( $title, $document ) {
    $title = 'Invoice';

    if ( $order = $document->order ) {

    $payment_method = $order->get_payment_method();
    $order_status = $order->get_status();

    if ($payment_method == 'stripe' && 'processing' == $order_status || 'completed' == $order_status ) {
    $title = 'GST RECEIPT';
    }

    else if ('completed' == $order_status && ($payment_method == 'bacs' || $payment_method == 'invoice' )) {
    $title = 'GST RECEIPT';
    }

    else if ('processing' == $order_status && ($payment_method == 'bacs' || $payment_method == 'invoice' )) {
    $title = 'TAX INVOICE';
    }

    else {
    $title = 'TAX INVOICE';
    }

    }
    return $title;
    }, 10, 2 );

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @iamhere,

    I’m glad to hear that you managed to achieve it by yourself! ??

    Let us know if you need anything else ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.