• Hi
    I’d like to have the invoice send only when a checkbox is checked in the checkout page, is it possible ? I’ve already put a checkbox in the checkout form.

    Thanks

    Pierre-Marie Delvern

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello Pierre-Marie,
    This is possible but would require a little bit of custom PHP coding. You could use the wpo_wcpdf_custom_attachment_condition.

    Here’s an example, you will need to tweak it so that it actually reads your checkbox value from the order data:

    
    add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_only_invoice_requested', 20, 4 );
    function wpo_wcpdf_only_invoice_requested( $attach, $order, $email_id, $document_type ) {
    	$wants_invoice = $order->get_meta('_invoice_checkbox');
    	if ( empty($wants_invoice) ) {
    		return false; // don't attach when invoice checkbox wasn't checked
    	}
    
    	return $attach; // use plugin attachment settings
    }
    

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘conditional invoice’ is closed to new replies.