• Resolved David Henry

    (@jane-blonde)


    great plugin!

    I’d like to add the text PAID as a red notice on the invoice once the payments has gone through.

    Is this possible?

    David

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @jane-blonde,

    Yes, you should be able to do that using an action hook from this table:?PDF template action hooks, and a bit of CSS.

    Hope it helps!

    Thread Starter David Henry

    (@jane-blonde)

    Perfect, thanks Jhonny.

    For anyone else looking for this solution, add the code below to your themes function.php file.

    //aDD paid TO iNVOICE
    add_action( ‘wpo_wcpdf_before_document_label’, ‘wpo_wcpdf_custom_text’, 10, 2 );
    function wpo_wcpdf_custom_text ($document_type, $order) {
    ?>
    PAID
    <?php
    }

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @jane-blonde,

    Your code will be displayed right after the PDF document has been created, even if the order was not actually paid.

    The WC_Order class from WooCommerce has a method called is_paid() which you can use to check if the order is paid already. By default, the order statuses treated as “paid statuses” are Processing and Completed, therefore, only when the order has reached these order status, the Paid status will be displayed as Paid, otherwise the output will be Unpaid.

    As an example, I used the method mentioned above in the following code snippet to achieve what you requested, but displaying the Payment Status after the order data:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Shows whether the invoice is paid or not
     */
    add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
    	if ( $document_type == 'invoice' ) {
    	?>
    	<tr class="is-paid">
    		<th>Payment Status:</th>
    		<td><?php echo ( $order->is_paid() ) ? 'Paid' : 'Unpaid' ?></td>
    	</tr>
    	<?php
    	}
    }, 10, 2 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Mark invoice as PAID’ is closed to new replies.