• Resolved polsola

    (@polsola)


    Hello, I’m creating a project where I have 3 different product lines, I would like to have different invoice numbers based on that

    Currently I’ve been able to do so with the hook wpo_wcpdf_formatted_document_number I can add different prefixs and do some extra logic, but I’m struggling to store the increments

    Is there a hook when an invoice is created I can add the logic to?
    I mean, when an invoice is created I want to check the order related so I can increment the count in the desired line

    Thanks

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

    (@yordansoares)

    Hi @polsola,

    Each of our documents has a single dedicated numbering system, therefore, we cannot provide further help for this as it is an advanced customization, and goes beyond the plugin support.

    That said, as it seems you’re a developer, here’s a tip as a courtesy:

    You could use the wpo_wcpdf_document_sequential_number_store filter hook (source) to set different number stores for each case. Our plugin would check that filter to decide what store to pick, and get the next document number from it.

    Here’s a draft code (not tested):

    /**
    * PDF Invoices & Packing Slips for WooCommerce - Premium Templates:
    * Se different number store(s) for the PDF Invoice based on specific conditions
    */
    add_filter( 'wpo_wcpdf_document_sequential_number_store', 'wpo_alternative_numbering_systems', 10, 2 );
    function wpo_alternative_numbering_systems( $number_store_name, $document ) {
    if ( ( $order = $document->order ) && 'invoice' === $document->get_type() ) {
    // Your logic goes here!
    // E.g.:
    // if ( $order->get_meta( 'custom_field_name' ) ) {
    // $number_store_name = 'your_custom_prefix_' . $number_store_name;
    // }

    }
    return $number_store_name;
    }

    Hope it helps!

Viewing 1 replies (of 1 total)

The topic ‘Different invoice number based on products’ is closed to new replies.