Hi @kluver @alexmigf,
Thanks for the fast aswer, Despite of your help i can’t resolve my problem,
I try to put your code on my web and add the function that calls a code that you put in the post to call the invoice, but it doesn’t work.
You can tell me what I’m doing wrong.`
I put my code in case you can help me.
This is html
<p class="form-row thwcfd-field-wrapper thwcfd-field-radio" id="billing_invoice_field" data-priority="50">
<label for="billing_invoice_invoice_yes" class="">
?Quieres factura por la compra?
<span class="optional">(opcional)</span>
</label>
<span class="woocommerce-input-wrapper"><input type="radio" class="input-radio " value="invoice_yes" name="billing_invoice" id="billing_invoice_invoice_yes" checked="checked">
<label for="billing_invoice_invoice_yes" class="radio ">Sí</label>
<input type="radio" class="input-radio " value="invoice_no" name="billing_invoice" id="billing_invoice_invoice_no">
<label for="billing_invoice_invoice_no" class="radio ">No</label>
</span>
</p>
<p class="form-row form-row-wide thwcfd-field-wrapper thwcfd-field-text" id="billing_company_field" data-priority="60">
<label for="billing_company" class="screen-reader-text">
Nombre de la empresa
<span class="optional">(opcional)</span>
</label><span class="woocommerce-input-wrapper">
<input type="text" class="input-text " name="billing_company" id="billing_company" placeholder="Nombre de la empresa" value="" autocomplete="organization" style="display: none;">
</span></p>
I want to send the invoice only if the client check.
<label for="billing_invoice_invoice_yes" class="radio ">Sí</label>
In in case that the client check no, don`t send it.
<label for="billing_invoice_invoice_no" class="radio ">No</label>
I add a conditional to call label and put in your code
add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_send_invoice_on_customer_request', 100, 4 );
//Conditional
if ('invoice_yes' == get_post_meta($post->ID, 'billing_invoice_field', true)) {
function wpo_wcpdf_send_invoice_on_customer_request( $condition, $order, $status, $template_type ) {
if ( $template_type == 'invoice' ) {
$condition = $order->get_meta( 'invoice_yes' ) == 1 ? true : false;
}
}
}