Title: create invoice in code
Last modified: March 14, 2024

---

# create invoice in code

 *  Resolved [moeclone](https://wordpress.org/support/users/moeclone/)
 * (@moeclone)
 * [2 years ago](https://wordpress.org/support/topic/create-invoice-in-code/)
 * Hello.
   please tell me how to create an invoice for payment in code?
 *     ```wp-block-code
       $invoice = new WCPDF_Invoice($order);
       $invoice->generate_invoice()
       ```
   
 * if you use this approach, then WCPDF_Invoice is undefined type.
 * What is the correct way to make it possible to create an invoice?
 * Or is it possible to set up an invoice to be created automatically and sent to
   the client after a certain period through the control panel? free version of 
   the plugin installed

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [dwpriv](https://wordpress.org/support/users/dwpriv/)
 * (@dwpriv)
 * [2 years ago](https://wordpress.org/support/topic/create-invoice-in-code/#post-17501379)
 * You could try this snippet to create an invoice if it doesn’t exist
 *     ```wp-block-code
       $invoice = wcpdf_get_document( 'invoice', $order, true );
       ```
   
 *  Thread Starter [moeclone](https://wordpress.org/support/users/moeclone/)
 * (@moeclone)
 * [2 years ago](https://wordpress.org/support/topic/create-invoice-in-code/#post-17502606)
 * please tell me where I can read about this? is there documentation?
 *  Thread Starter [moeclone](https://wordpress.org/support/users/moeclone/)
 * (@moeclone)
 * [2 years ago](https://wordpress.org/support/topic/create-invoice-in-code/#post-17502846)
 * How can I then get a link to this invoice to send it to the client?
 *  Plugin Contributor [dwpriv](https://wordpress.org/support/users/dwpriv/)
 * (@dwpriv)
 * [2 years ago](https://wordpress.org/support/topic/create-invoice-in-code/#post-17503742)
 * There isn’t a documentation for this specifically.
 * You can create a download link and share it with a snippet like this
 *     ```wp-block-code
       $pdf_url = admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $order->get_id() . '&order_key=' . $order->get_order_key() );
   
       echo '<p><a href="' . $pdf_url. '>Download your invoice</a></p>';
       ```
   
 * You can use this with the function to print the download link.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘create invoice in code’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [dwpriv](https://wordpress.org/support/users/dwpriv/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/create-invoice-in-code/#post-17503742)
 * Status: resolved