• Hi there,

    I was wondering how do you trigger the generation of an invoice ?
    I can get the invoice number like this get_post_meta ( $this -> id, '_wcpdf_invoice_number', true ) but I can get it to generate if this returns an empty string. Is there a function like generate_order_invoice($order_id) ?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • try that:
    $order_no = $this->order->get_id();

    Thread Starter db306

    (@db306)

    That returns the id of the order, it does not trigger the creation of a pdf invoice.

    Plugin Contributor Ewout

    (@pomegranate)

    Hi! Do you mean the generation of an invoice number or do you want the actual PDF data?
    This creates the invoice number & date:

    
        global $wpo_wcpdf;
        $invoice_number = $wpo_wcpdf->export->set_invoice_number( $order_id );
        $invoice_date = get_post_meta($order_id,'_wcpdf_invoice_date',true);
    
        // add invoice date if it doesn't exist
        if ( empty($invoice_date) ) {
            $invoice_date = current_time('mysql');
            update_post_meta( $order_id, '_wcpdf_invoice_date', $invoice_date );
        }
    

    I’m working on a new release that is going to make stuff like this much easier/more intuitive, but for now this should work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘generate invoice dynamically? hook’ is closed to new replies.