• Resolved Danb3434

    (@danb3434)


    Hi, I’m looking for a way to change the invoice title from ‘invoice’ to the order number. I have tried using filters in my child theme functions but cannot get it to work.

    Any help would be appreciated.

    Kind regards,

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    There’s some documentation on this subject here: Change the document title

    To replace the invoice title with the order number, you can use the following snippet:

    
    add_filter( 'wpo_wcpdf_invoice_title', 'wpo_wcpdf_invoice_title', 10, 2 );
    function wpo_wcpdf_invoice_title ( $title, $document ) {
        if (!empty($document->order)) {
            $title = $document->order->get_order_number();
        }
        return $title;
    }
    

    Do note that this will change the title on the buttons too. If you only want to change the title in the document itself, you will need to create a custom template.

    Thread Starter Danb3434

    (@danb3434)

    Thank you this works perfectly on the invoice!
    When you say buttons, do you mean the buttons on the orders page? Also, is there a way to include a # before the order number?

    Thank you

    Thread Starter Danb3434

    (@danb3434)

    Got it working with:

    add_filter( 'wpo_wcpdf_invoice_title', 'wpo_wcpdf_invoice_title', 10, 2 );
    function wpo_wcpdf_invoice_title ( $title, $document ) {
        if (!empty($document->order)) {
            $title = '#'.$document->order->get_order_number();
        }
        return $title;
    }

    thanks for your help!

    Thread Starter Danb3434

    (@danb3434)

    @pomegranate do you also know if there is a way to move the logo to the top right instead of the top left?

    I tried using:

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
        ?>
    	td.shop-info {display: none !important;}
    	td.header > img {float:right !important;}
        <?php
    }

    Whilst this did move the logo to the right, it sat on top of some other text.

    Kind regards,

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @danb3434

    Try this:

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
        ?>
    	td.shop-info {display: none !important;}
    	td.header > img {float:right !important; margin-right: 40%;}
        <?php
    }
    Thread Starter Danb3434

    (@danb3434)

    Hi @alexmigf,

    Thanks for the suggestion, I just tried it and it kind of moved the logo into the middle of the page.
    See the original issue here:

    View post on imgur.com

    Kind regards,

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @danb3434

    Can you show me where to want to place it?

    Thread Starter Danb3434

    (@danb3434)

    Hi @alexmigf, thanks for the quick reply!

    I’m looking to have the logo on the right, the original code I showed did do this, so the location of the logo is correct.
    The issue though is that it is now sitting on top of other pieces of text. See the full invoice here:

    View post on imgur.com

    Let me know if I can clarify any further.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @danb3434

    Try this:

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
        ?>
    	td.shop-info { display:none; }
    	td.header { text-align:right; }
        <?php
    }

    Let me know.

    Thread Starter Danb3434

    (@danb3434)

    @alexmigf works perfectly, thank you for your help!!

    Plugin Contributor alexmigf

    (@alexmigf)

    You’re welcome ??

    Have a nice day!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘replace invoice title with order number’ is closed to new replies.