Hi @kybernetikservices,
Sorry for the late reply!
To migrate the invoice number and its date from the PDF invoices plugin from YITH to ours, follow these steps:
- Find which is the Next invoice number located under YITH > PDF Invoice and copy its value. Also, in this same page, find the invoice suffix, prefix, and format.
- Now, go to WooCommerce?> PDF?Invoices?> Documents?> Invoice and find the Next?invoice?number and enter the value you copy in the first step. Here, you’ll also find the Number format section, in which you can replicate your number format settings from YITH, but please note that the invoice format need to be merged in the prefix and/or suffix.
E.g. if the prefix in YITH was F
, the suffix US
, and your format [prefix]-[number]/[suffix]
, you’ll need to configure the Number format in our plugin in this way:
— Prefix: F-
— Suffix: /US
- Finally, add this code snippet to your site:
/**
* WooCommerce PDF Invoices & Packing Slips:
* Migrate invoice numbers from YITH WooCommerce PDF Invoice and Shipping List Premium
*/
add_filter( 'wpo_wcpdf_invoice_get_date', function( $date, $document ) {
if ( $document->get_type() == 'invoice' && $order = $document->order ) {
// Get invoice date
if ( $legacy_date = $order->get_meta('_ywpi_invoice_date') ) {
$date = new \WC_DateTime( "@{$legacy_date}", new \DateTimeZone( 'UTC' ) );
$document->set_date( $date );
}
}
return $date;
}, 10, 2 );
add_filter( 'wpo_wcpdf_external_invoice_number_enabled', '__return_true' );
add_filter( 'wpo_wcpdf_external_invoice_number', function( $number, $document ) {
if ( ! empty( $document->order ) ) {
// Get invoice formatted number
$number = $document->order->get_meta( '_ywpi_invoice_formatted_number' ); // if $number is empty, the plugin will generate a new number
}
return $number;
}, 10, 2 );
If you haven’t worked with code snippets (actions/filters) or functions.php
before, read this guide: How to use filters
Let me know if it worked! ??