• Resolved stijndemulder

    (@stijndemulder)


    Hi,

    Is it possible to let the client decide to receive an invoice by checkbox/radio button?

    Or a hook to develop on myself?

Viewing 1 replies (of 1 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @stijndemulder,

    This is certainly possible using a checkout custom field. You could use a plugin like Checkout Field Editor, for instance, to add your checkbox/radio custom field to the billing fields. Let’s say that you named your field billing_want_invoice and the value when checked is yes, then you could add a code snippet like this to enable the invoice only if the customer checked the field:

    /**
     * Enable invoice if customer wants it
     */
    add_filter( 'wpo_wcpdf_document_is_allowed', 'wpo_wcpdf_allow_invoice_or_proforma_based_on_customer_selection', 10, 2 );
    function wpo_wcpdf_allow_invoice_or_proforma_based_on_customer_selection( $allowed, $document ) {
    	if ( $order = $document->order ) {
    		if ( $want_invoice = $order->get_meta( 'billing_want_invoice' ) ) {
    			if( $document->type == 'invoice') {
    				$allowed = ($want_invoice == 'yes') ? true : false;
    			}
    		}
    	}
    	return $allowed;
    }

    Let me know if you manage to make it work ??

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