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

    (@pomegranate)

    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

    (@rshinall)

    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

    (@pomegranate)

    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

    (@pomegranate)

    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.