• Resolved kraeMit

    (@kraemit)


    Hi,

    can this be done?

    I’m in creating older incvoices manualy. Creating bulk invocices including correct numbers works fine. Happy me! ??

    But I need to update the Invoice Date to Order Date. I tried in the settings under ‘Documents’,’Invoice’ to set Display invoice date = Order date. But this does not work.

    Any tips please?

    Thanks!
    All the best!
    kraeMit

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @kraemit,

    You have two ways to do this:

    1. If you want to use the order date as invoice date for all your orders, not only the order placed before today, you can select Order Date in the Display invoice date option, under WooCommerce?> PDF?Invoices?> Documents?> Invoice.
    2. Or add this code snippet to your site to only use the order date as invoice date if the order was created before April 22nd, 2022 (today):
      /**
       * Set the order date as invoice date for order created before April 22nd, 2022
       */
      add_filter( 'wpo_wcpdf_invoice_get_date', function( $date, $document ) {
      	if ( $document->get_type() == 'invoice' && $order = $document->order ) {		
      		$order_date = $document->order->get_date_created();
      		$order_date_timestamp = $order_date->getTimestamp();
      		if ( $order_date_timestamp < strtotime('2022-04-22 23:59:59') ) {
      			$date = new \WC_DateTime( "@{$order_date_timestamp}", new \DateTimeZone( 'UTC' ) );
      			$document->set_date( $date );
      		}
      	}
      	return $date;
      }, 10, 2 );
    Thread Starter kraeMit

    (@kraemit)

    Hi @yordansoares,
    thanks for your fast support!

    I will check both, but I think the first one does the trick as wanted.

    All the best!

    Regards
    kraeMit

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m happy to hear that it worked for you!

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and all the best with your store!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to set Invoice Date = Order Date?’ is closed to new replies.