• Resolved NikkaG

    (@nikkag)


    Hi,

    I’m trying to change button text in admin Edit Order page (screenshot):
    from ‘PDF Invoice’ to ‘MY PDF Invoice’
    from ‘PDF Packing Slip’ >>> ‘MY PDF Packing Slip’

    I found the filter hook ‘wpo_wcpdf_myaccount_button_text’ but I’m doing something wrong, can anyone help me?
    Thanks.

    add_filter( 'wpo_wcpdf_myaccount_button_text', 'my_wpo_wcpdf_myaccount_button_text', 10, 2 );
    function my_wpo_wcpdf_myaccount_button_text ( $button_text, $invoice ) {
    	$button_text_new = 'MY PDF Invoice';
    	return $button_text_new;
    }
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor dwpriv

    (@dwpriv)

    @nikkag try these snippets

    add_filter( 'wpo_wcpdf_myaccount_button_text', function( $document_title, $invoice ) {	
    	return 'My PDF Invoice';
    }, 10, 2 );
    
    add_filter( 'wpo_wcpdf_myaccount_packing_slip_button', function( $document_title, $document ) {
    	return 'My PDF Packing Slip';
    }, 10, 2 );
    Thread Starter NikkaG

    (@nikkag)

    It seems they don’t work. I also tried in a demo website with Storefront theme and few plugins.

    Plugin Contributor dwpriv

    (@dwpriv)

    @nikkag

    how are you adding these snippets?

    Thread Starter NikkaG

    (@nikkag)

    I add the snippets in functions.php

    Plugin Contributor dwpriv

    (@dwpriv)

    @nikkag I’m not having any trouble using the snippets. Could you show me a screenshot of how you added it to the functions.php fie, please? Does it also not work with a code snippet plugin?

    Thread Starter NikkaG

    (@nikkag)

    This is the code added in functions.php. I added it in the child theme but I tried also in master theme.

    This is the code added with a code snippet plugin.

    Plugin Contributor dwpriv

    (@dwpriv)

    @nikkag in the top right corner of your screenshot, your snippet seems to be inactive. Could you hit the switch to activate it and see if it works?

    Thread Starter NikkaG

    (@nikkag)

    @dwpriv There was a misunderstanding, I want to change the text of the button in the backend, in the admin Edit Order page (screenshot).
    I now discovered that the code works, but it changes the text of the buttons in the customer My Account page (screenshot).

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @nikkag,

    Try this code snippet:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Customize the PDF Invoice title
     */
    add_filter( 'wpo_wcpdf_invoice_title', function( $title, $document ) {
        $title = 'Receipt';
        return $title;
    }, 10, 2 );
    Thread Starter NikkaG

    (@nikkag)

    Thanks!

    And, for anybody else, ‘wpo_wcpdf_packing_slip_title’ is the related hook for Packing Slip button.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    That’s right, @nikkag: We follow the same pattern for all our PDF documents 🙂

    By the way, 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!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Change button text – Filter hook’ is closed to new replies.