We store the document data within the order data, but not the encrypted PDF document as is.
However, you could try storing the packing slip link within the order data, following the steps explained below:
1. Go to WooCommerce > PDF Invoices > Status, and set the Document link access type setting to Guest:
2. Activate the following code snippet in your site, in order to save the packing slip link within the '_wcpdf_packing_slip_link' meta key:
/**
* PDF Invoices & Packing Slips for WooCommerce:
* Save the PDF packing slip link for guest access in the order data.
* Note: Requires v3.6.0 or higher
*/
add_action( 'wpo_wcpdf_before_document', function( $document_type, $order ) {
if( ! empty( $order ) && $document_type == 'packing-slip' ) {
$debug_settings = get_option( 'wpo_wcpdf_settings_debug', array() );
if( isset( $debug_settings['document_link_access_type'] ) && $debug_settings['document_link_access_type'] === 'guest' ) {
$pdf_url = admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type='.$document_type.'&order_ids=' . $order->get_id() . '&order_key=' . $order->get_order_key() );
// Save the PDF invoice link under the '_wcpdf_invoice_link' meta key
update_post_meta( $order->get_id(), '_wcpdf_'.$document_type.'_link', esc_url( $pdf_url ) );
}
}
}, 10, 2 );
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
Please note that _wcpdf_packing_slip_link meta key will be hidden. However, you can remove the underscore (_) under the 12th line, if you want to display the custom fields are, within the single order view:
After I do as you indicated above, what should I do in my Website PHP code? Continue so that can print the Packaging-slip.php from the PHP site?
After saving the guest URL for the PDF document, within the WooCommerce order data, you will be able to get it from your PHP app, using the WooCommerce REST API.
For instance, you could retrieve the JSON response like this (after configuring your app with the steps explained in this guide: Getting started with the REST API):
// 123 is the order ID
https://example.com/wp-json/wc/v3/orders/123
Then search by _wcpdf_invoice_link within the meta_data field.