• Resolved nenosw

    (@nenosw)


    Hi

    My goal is to add payment due date and bank info to the invoice pdf, but only for invoices with direct bank transfer as payment method. I have found here on the forum ways to add the due date and bank info, but how can I do this only for orders with a certain payment method?

    Thanks

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

    (@kluver)

    Hi @nenosw,

    You can check for the used payment method via:

    $order->get_payment_method()

    So adding a due date on the invoice only for orders paid via direct bank transfer (BACS) would look something like this:

    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_due_date', 10, 2 );
    function wpo_wcpdf_due_date ( $template_type, $order ) {
        if ( $template_type == 'invoice' && $order->get_payment_method() == 'bacs' ) { // put due date only on invoice and when payment method is bacs
            $invoice = wcpdf_get_invoice( $order );
            if ( $invoice_date = $invoice->get_date() ) {
                $due_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date->date_i18n( 'Y-m-d H:i:s' ) . ' + 14 days' ) );
                ?>
                <tr class="due-date">
                    <th>Due Date:</th>
                    <td><?php echo $due_date; ?></td>
                </tr>
                <?php
            }
        }
    }
    • This reply was modified 4 years, 1 month ago by kluver.
Viewing 1 replies (of 1 total)
  • The topic ‘Due date and bank info only on invoices with payment method direct bank transfer’ is closed to new replies.