Support » Plugin: WP-Invoice - Web Invoice and Billing » Showing paid date on receipt

  • Resolved ognistik

    (@ognistik)


    Hello,

    Is there a way to show the date an invoice was paid on receipt? Other than the history log? I am specifically looking for a way to display it on the PDF (I have purchased this add-on). The new pdf template (remastered) is awesome, I just really wish it had this little thing. It is very important and it makes the document more official. If there was a code or a string or if you can guide me where to look for this I would appreciate it, once I know I can probably add this to the template myself if no other option.

    Thank you!

    https://wordpress.org/plugins/wp-invoice/

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

    (@anton-korotkoff)

    Hello,

    unfortunately, we don’t have such function yet but here is how you can do this:

    you can add this function into the functions.php of your theme

    function invoice_paid_date( $invoice_id, $return = false ) {
    	global $wpdb;
    
    	$invoice_post_id = wpi_invoice_id_to_post_id($invoice_id);
    
    	$results = $wpdb->get_results("
    		SELECT time
    		FROM {$wpdb->base_prefix}wpi_object_log
    		WHERE object_id = '$invoice_post_id'
    			AND value = 'paid'
    	", ARRAY_N);
    
    	if ( empty($results) ) return null;
    
    	$date = date( get_option('date_format').' \a\t '.get_option('time_format'), $results[0][0] );
    
    	if ( $return ) return $date;
    
    	echo $date;
    }

    then find remastered template in /wp-content/plugins/wp-invoice-pdf/static/views and copy it to your theme into /wp-content/themes/your_theme/wpi folder

    after that just add to copied file <?php invoice_paid_date( $template->get_ID() ); ?> in place where you need paid date to be displayed.

    Let me know if that was successful.
    Thank you.

    Thread Starter ognistik

    (@ognistik)

    I almost got it to work. I found that this won’t exactly work because I am using “Custom ID” for my invoices. If I don’t do the custom ID this works perfectly.

    So, I am thinking that I have to change the get_ID() for something that gives me the real number. Could you advice me on this?

    Plugin Contributor Anton Korotkoff

    (@anton-korotkoff)

    Yeah, I had to consider this…

    So in this case try to use

    $invoice->data['ID']

    instead of

    $template->get_ID()
    Thread Starter ognistik

    (@ognistik)

    Works perfect now. Thank you so much!

    Plugin Contributor Anton Korotkoff

    (@anton-korotkoff)

    You are welcome! Could you please mark thread as resolved then?

    Thanks

    Thread Starter ognistik

    (@ognistik)

    Done. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Showing paid date on receipt’ is closed to new replies.