• Resolved lolitsjohnnyboy

    (@lolitsjohnnyboy)


    I’ve a big problem at the moment. I’m using the PayPal PLUS plugin for my payments. During the payment process, an API class named Patch is used to set an invoice number:

    $invoice_patch = new Patch();
    $invoice_patch
    	->setOp( 'add' )
    	->setPath( '/transactions/0/invoice_number' )
    	->setValue( 'PATH HERE' );

    The problem is that I want to use the same invoice number given by your plugin for PayPal payments. I’ve tried to get the invoice number this way:

    $invoice        = wcpdf_get_invoice( $this->order->get_id() );
    $invoice_number = $invoice->get_number();

    and logged it out but the result is empty. I think you’re setting the number after a payment – right? If yes, how can I deal with this so that I can use your invoice number here?

    Thanks for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    The way you currently read the invoice number only works if you have already created the invoice. If you want to trigger the invoice creation you can set the second argument to true:

    
    $invoice        = wcpdf_get_invoice( $this->order->get_id(), true );
    
    Thread Starter lolitsjohnnyboy

    (@lolitsjohnnyboy)

    Worked! Perfect. Maybe you can add a method description so that developers know whats the init means.

    BG to u!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get invoice number during payment’ is closed to new replies.