• Hi,

    1) Code for both completed and processing orders:

    I was reading the previous post here: https://wordpress.org/support/topic/mark-invoice-as-paid-or-not-paid/

    The code to add “- PAID” works great for “completed” orders. Would it be possible to modify it so that it works for EITHER “completed” or “processing” orders? I tried to modify it myself but without success 🙁

    This is the code:
    add_action( ‘wpo_wcpdf_after_document_label’, ‘wpo_wcpdf_paid_label’, 10, 2 );
    function wpo_wcpdf_paid_label( $template_type, $order ) {
    if ( $order->get_status() == ‘completed’ && $template_type == ‘invoice’ ) {
    ?>
    <style type=”text/css”>
    .document-type-label::after { content: ” – PAID”; }
    </style>
    <?php
    }
    }

    2) In the same previous post you also shared the code to display a picture when the order is “complete” as follow:

    add_action( ‘wpo_wcpdf_before_document’, ‘wpo_wcpdf_paid_label’, 10, 2 );
    function wpo_wcpdf_paid_label( $template_type, $order ) {
    if ( $order->get_status() == ‘completed’ && $template_type == ‘invoice’ ) {
    ?>

    <?php
    }
    }

    – I replaced http://wpovernight.com/dont_print_emails.jpg
    with /www/tripusafrance_204/public/wp-content/themes/tesseract-free-theme/images/invoicepaid.jpg which is where my picture is located on my server.
    – I copied the code in my function.php file

    But it makes my website crash and tells me that there is a “critical error” Do you have any idea why this code does not work?

    Many thanks,
    Julia

Viewing 1 replies (of 1 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @tripusafrance,

    You could use the wpo_wcpdf_invoice_title filter and the is_paid function (WooCommerce views processing and completed orders as paid):

    add_filter( 'wpo_wcpdf_invoice_title', 'wpo_wcpdf_expand_title_on_paid_status', 10, 2 );
    function wpo_wcpdf_expand_title_on_paid_status ( $title, $document = null ) {
    	if ( $order = $document->order ) { 
    		if ( $order->is_paid() ) $title .= ' - PAID';
    	}
    	return $title;
    }

    With regards to the image, can you check what the actual error is? You can do so via WooCommerce > Status > Logs and check for an error that begins with wpo_wcpdf_ with a timestamp matching when you tried to create your invoice.

    There probably is a small error somewhere in your snippet or you are not giving the correct path of the image. The full error will hopefully clear up what is going wrong.

Viewing 1 replies (of 1 total)

The topic ‘Mark invoice as paid for “processing” order’ is closed to new replies.