Hi @aiyubpanara,
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 want, 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