diff --git a/includes/class-wcpdf-main.php b/includes/class-wcpdf-main.php index 7e5eb05f8..eb41f8deb 100644 --- a/includes/class-wcpdf-main.php +++ b/includes/class-wcpdf-main.php @@ -124,6 +124,8 @@ public function __construct() { add_action( 'wpo_wcpdf_save_document', array( $this, 'wc_webhook_trigger' ), 10, 2 ); add_action( 'wpo_wcpdf_after_order_data', array( $this, 'display_due_date' ), 10, 2 ); + + add_action( 'wpo_wcpdf_delete_document', array( $this, 'log_document_deletion_to_order_notes' ) ); } /** @@ -1314,6 +1316,22 @@ public function log_document_creation_to_order_notes( $document, $trigger ) { } } + /** + * Log document deletion to order notes. + * + * @param object $document + * + * @return void + */ + public function log_document_deletion_to_order_notes( object $document ): void { + if ( ! empty( WPO_WCPDF()->settings->debug_settings['log_to_order_notes'] ) ) { + /* translators: document title */ + $message = __( 'PDF %s deleted.', 'woocommerce-pdf-invoices-packing-slips' ); + $note = sprintf( $message, $document->get_title() ); + $this->log_to_order_notes( $note, $document ); + } + } + /** * Log document printed to order notes * diff --git a/includes/settings/class-wcpdf-settings-debug.php b/includes/settings/class-wcpdf-settings-debug.php index 76ac1bca1..a7d5de467 100644 --- a/includes/settings/class-wcpdf-settings-debug.php +++ b/includes/settings/class-wcpdf-settings-debug.php @@ -830,7 +830,7 @@ public function init_settings() { 'args' => array( 'option_name' => $option_name, 'id' => 'log_to_order_notes', - 'description' => __( 'Log PDF document creation and mark/unmark as printed to order notes.', 'woocommerce-pdf-invoices-packing-slips' ), + 'description' => __( 'Log PDF document creation, deletion, and mark/unmark as printed to order notes.', 'woocommerce-pdf-invoices-packing-slips' ), ) ), array(