• I am trying to use Woocommerce PDF Invoices and Packing Slips but only want invoicing to be turned on for specific products and not, necessarily, for orders. Basically, if a customer orders a certain product, (in this case they are registering for an event/class) we want to give them the option to either “Pay Now” or “Invoice Me”. There should never be another product in the order, but if there was the invoice option should still be available. However, for any other products in this store the invoicing option should not be an option. Is this a possibility using PDF Invoices and Packing Slips? Also, it would be nice to have a “Pay Now” link on the emailed invoice.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Invoice is base with the order. If you want to set the Invoice me before completing the order, you have found the hook of document create a hook, then set up the order is null action.

    Plugin Contributor Ewout

    (@pomegranate)

    What you describe sounds more like a payment gateway feature than something that we could do from within the PDF Invoice plugin – this merely creates a PDF based on an order after it has been created. We can limit the invoice to specific payment gateways, but the payment gateway itself is out of scope for this plugin.

    Thread Starter ronhorne50

    (@ronhorne50)

    Thank you for your input on this. I am thinking that I might be able to custom code a checkbox in the product page admin that will “Allow Invoicing” and then have it be an option at checkout when box is checked. If not checked, “Invoice Me” will become hidden as an option. Does this make sense? I know this sounds a little strange but client needs invoicing for a only limited number of products.

    Plugin Contributor kluver

    (@kluver)

    Hi @ronhorne50,

    A possible solution might be to add a custom invoice payment gateway. Either with an available plugin or yourself with some custom code. And then check the products in your cart on checkout.

    //Check products in cart on checkout
    add_action( 'woocommerce_after_checkout_form', 'woocommerce_after_checkout_form', 10, 1 );
    function woocommerce_after_checkout_form( $checkout ) {
    	foreach( WC()->cart->get_cart() as $cart_item ){
    		$product_id = $cart_item['product_id'];
    		//Additional logic here...
    	}
    }

    Based on that disable and hide the invoice payment gateway with some JavaScript.

    Plugin Contributor Ewout

    (@pomegranate)

    Small addition to kluvers message above, once you have established the checkout field correctly, allowing/disallowing for the invoice to be generated is quite simple, using the wpo_wcpdf_document_is_allowed filter. Here’s an example:

    
    add_filter( 'wpo_wcpdf_document_is_allowed', 'wpo_wcpdf_invoice_restriction', 10, 2 );
    function wpo_wcpdf_invoice_restriction( $is_allowed, $document ) {
    	if ( $document->get_type() == 'invoice' && !empty($document->order) ) {
    		$custom_field_meta_key = 'your_meta_key'; // replace with your custom checkout field meta key
    		$send_invoice = $document->order->get_meta( $custom_field_meta_key );
    		if ( $send_invoice === 'expected_value' ) {
    			$is_allowed = true;
    		} else {
    			$is_allowed = false;
    		}
    	}
    	return $is_allowed;
    }
    

    Hope that helps! This is quite custom and therefor out of scope for support that we can offer for the plugin, but hopefully the pointers above will get you on track with this (otherwise, it’s surely enough for an experiences WooCommerce/WordPress developer to make this work). Good luck!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Woocommerce PDF Invoices & PS Plugin Specific to Product – Not Order’ is closed to new replies.