• Resolved netart.gr

    (@geokantze)


    Hello there and thanks for your great plugin.

    I have noticed that when I have a cancelled order, its pdf invoice doesn’t warn me about it as it used to.

    In the past there was a message in the pdf of each cancelled order

    View post on imgur.com

    Can you please, guide me to add this message?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @geokantze,

    The ‘CANCELLED’ addition is not something that our plugin adds by default. Was this custom made for you by an external developer? If so I would contact him/her to see why it no longer appears on your document.

    Thread Starter netart.gr

    (@geokantze)

    Hi @kluver!
    Thank you for your quick answer and sorry for my delay.

    It should be custom made by the previous developer who was supporting this eshop.

    Any idea of how I would implement this, please? Any tip or recommended function/class I should use?

    (PS it would be very handy if in the future your plugin will show a “label” for cancelled invoices. It is much easier for the logistics person that checks the invoices to know which of them are cancelled! ?? )

    Plugin Contributor kluver

    (@kluver)

    Hi @geokantze,

    You can add ‘Cancelled’ to the invoice title when the order status is cancelled with a small code snippet:

    add_filter( 'wpo_wcpdf_invoice_title', 'wpo_wcpdf_invoice_custom_title_for_canceled_order', 10, 2 );
    function wpo_wcpdf_invoice_custom_title_for_canceled_order ( $title, $document = null ) { 
    	if ( !empty($document) && !empty($document->order) ) {
    		if ( $document->order->get_status() == 'cancelled' ) {
    			$title .= ' - CANCELLED';
    		}
    	}
    	return $title;    
    }

    This code snippet should be placed in the functions.php of your child theme or added with a plugin like Code Snippets. If you haven’t worked with code snippets or functions.php before please read this: How to use filters

    Another solution might be to make sure no invoices are created for cancelled orders? For instance by only creating invoices on completed order status. (You can set this via WooCommerce > PDF Invoices > Documents > Invoice > Attach to).

    Thread Starter netart.gr

    (@geokantze)

    Hello and sorry for my delayed answer. Your suggestion unfortunately didn’t work for me. But it helped me to find the solution by search the old programmer’s theme (inside functions.php file).

    The code that did the trick for me

    add_action( 'wpo_wcpdf_after_document_label', 'wpo_wcpdf_cancelled_invoice_stamp', 10, 2 );
    function wpo_wcpdf_cancelled_invoice_stamp($template_type, $order) {
        $order_status = $order->get_status();
        if ($template_type == 'invoice' && $order_status == 'cancelled') {
            echo '<h1><strong>CANCELLED</strong></h1>';
        }
    }

    Again, a big thank you for your great plugin and support!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Invoices for Cancelled Orders don’t have “CANCELLED” message’ is closed to new replies.