Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    If your payment gateway properly stores the paid date (_paid_date custom field), you can check that and add text conditionally:

    add_action( 'wpo_wcpdf_after_document_label', 'wpo_wcpdf_paid_label', 10, 2 );
    function wpo_wcpdf_paid_label($template_type, $order) {
        if (!empty($order->paid_date)) {
            echo '<h1>PAID</h1>';
        }
    }

    This goes into your theme functions.php or a plugin like Code Snippets. Read this if you’re new to this!

    Ewout

    Sorry couldn’t get it working, I am using flatsome theme and they do use _paid_date custom field. Any other way ?

    Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    This is independent from the theme, it’s the payment gateway that determines whether the _paid_date is saved. Where did you see this paid date? You can only see this in the database (wp_postmeta table) or with a plugin like the WooCommerce Store Toolkit.
    I just tested again and it worked for me, but again, only in orders which have the _paid_date custom field!

    Here’s a slightly improved version, that limits this to the invoice (otherwise it will show this on the packing slip too):

    add_action( 'wpo_wcpdf_after_document_label', 'wpo_wcpdf_paid_label', 10, 2 );
    function wpo_wcpdf_paid_label($template_type, $order) {
        if ( $template_type == 'invoice' && !empty($order->paid_date)) {
            echo '<h1>PAID</h1>';
        }
    }

    If you used code snippet, double check you activated the snippet!
    Ewout

    Thank you for quick response, I thought woocommerce adds it automatically once the payment status is completed, I have checked my postmeta table and couldn’t find the _paid_date meta key. I am using only paypal for payment, in this case how shall I solve this problem, before i was using woocommerce pdf invoice, they generated paid automatically once order is completed, is there any way we can do it here ?

    this plugin is really beautiful and i don’t want to change it, could you please give me a solution or yes how can we add that _paid_date custom field as well ?

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Debendra,
    I see, if the completed order status is good for you than that’s another possibility – order completed doesn’t mean that the order is actually paid for all shops (it doesn’t tell you whether the order was actually paid), but if that works for you, you can use:

    add_action( 'wpo_wcpdf_after_document_label', 'wpo_wcpdf_paid_label', 10, 2 );
    function wpo_wcpdf_paid_label($template_type, $order) {
        $order_status = $order->get_status();
        if ( $template_type == 'invoice' && $order_status == 'completed' ) {
            echo '<h1>PAID</h1>';
        }
    }

    Hope that helps!

    Contact the gateway developers about this, they really should use the WooCommerce payment_complete() function. It’s as simple as calling

    $order->payment_complete();

    After the transaction has succeeded! This is basic stuff and has numerous other benefits… (WooCommerce code here for reference).

    Hope that helps!
    Ewout

    Wow thank you for making me clear. You are awesome.

    thank you again

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘"PAID" Stamp On Paid Invoices’ is closed to new replies.