Title: Call from external script?
Last modified: August 21, 2016

---

# Call from external script?

 *  Resolved [rshinall](https://wordpress.org/support/users/rshinall/)
 * (@rshinall)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/call-from-external-script/)
 * Hello! Is it possible to call the invoice and packing slip routines from my PHP
   script that processes our orders? I’m hoping I can include wp-load.php and call
   it somehow. Thank you for your help!
 * [https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)

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

 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/call-from-external-script/#post-5162552)
 * Hi rshinall,
    The plugin is loaded into `$wpo_wcpdf` object, so if you call that
   object globally, you can access all of its functions.
 * For example, the following code will generate a packing slip and save it to your
   predefined path:
 *     ```
       global $wpo_wcpdf;
       $order_id = 999; // define your order_id or get it from an existing $order object.
       $pdf = $wpo_wcpdf->export->get_pdf( 'packing-slip', (array) $order_id ); // replace 'packing-slip' by 'invoice' to get the invoice
   
       $pdf_path = 'path/for/pdf/storage/';
       $pdf_filename = 'packing-slip.pdf';
       ```
   
 * Hope that helps you in the right direction!
 *  Thread Starter [rshinall](https://wordpress.org/support/users/rshinall/)
 * (@rshinall)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/call-from-external-script/#post-5162593)
 * Some progress, but I am getting:
 * PHP Fatal error: Call to a member function get_pdf() on a non-object
 * I have included wp-load.php at the beginning of the script. Is there something
   I am missing? here is what I am working with:
 *     ```
       <?php
       define('WP_USE_THEMES', false);
       require_once( "/path_to/wp-load.php" );
   
       global $wpo_wcpdf;
   
       $order_id = 1234; // define your order_id or get it from an existing $order object.
       $pdf = $wpo_wcpdf->export->get_pdf( 'packing-slip', (array) $order_id ); // replace 'packing-slip' by 'invoice' to get the invoice
   
       $pdf_path = 'path/for/pdf/storage/';
       $pdf_filename = 'packing-slip.pdf';
       ?>
       ```
   
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/call-from-external-script/#post-5162600)
 * I think this is because the export class is not loaded yet, which happens at 
   the `init` hook. I have no experience with loading wordpress like this via `wp-
   load.php`, so I’m afraid I won’t be able to help you…
    The only thing that I 
   can think of is to call a `do_action('init')`, but to be honest I’m not sure 
   if that will solve your problems or only reveal more.
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/call-from-external-script/#post-5162700)
 * I’m closing this thread because of inactivity and also because it’s beyond the
   scope of the free support.
 * good luck though!

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

The topic ‘Call from external script?’ 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/)

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [external](https://wordpress.org/support/topic-tag/external/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 4 replies
 * 2 participants
 * Last reply from: [Ewout](https://wordpress.org/support/users/pomegranate/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/call-from-external-script/#post-5162700)
 * Status: resolved