Sending an invoice only when the checkbox is checked – problem
-
I have added a checkbox “I want an invoice”
If I use code:add_filter( 'wpo_wcpdf_document_is_allowed', 'wpo_wcpdf_allow_invoice_if_checkbox_is_selected', 10, 2 ); function wpo_wcpdf_allow_invoice_if_checkbox_is_selected( $allowed, $document ) { if ( $document->exists() ) { return $allowed; } if ( $document->order && $document->get_type() == 'invoice') { $checkbox = $document->order->get_meta( '_if_invoice' ); $allowed = wc_string_to_bool( $checkbox ); } return $allowed; }
The invoice is created and sent only if I check the checkbox
But then I can’t add the invoice manually in the orders panel.
I would like to be able to add an invoice manually sometimes.The code
add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_send_invoice_on_customer_request', 100, 4 ); function wpo_wcpdf_send_invoice_on_customer_request( $condition, $order, $status, $template_type ) { if ( $template_type == 'invoice' ) { $condition = $order->get_meta( '_if_invoice' ) == 1 ? true : false; } }
doesn’t work at all for me, it neither attaches nor creates an invoice regardless of the checkbox.
I found both snippets here, but the second one doesn’t work and the first one doesn’t allow adding an invoice in the panel. Is there any solution?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Sending an invoice only when the checkbox is checked – problem’ is closed to new replies.