On version 3.6.0, launched 3 days ago (see changelog), we have improved the setting to configure the access type for the document link, under the Status tab:
Since there are more options now, we update the setting key from 'guest_access' to document_link_access_type, that is why the code stopped working.
However, I have updated the code, so it is working again for v3.6.0 or higher:
/**
* PDF Invoices & Packing Slips for WooCommerce:
* Save the PDF invoice 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 == 'invoice' ) {
$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_document_link' meta key
update_post_meta( $order->get_id(), '_wcpdf_document_link', esc_url( $pdf_url ) );
}
}
}, 10, 2 );