Viewing 11 replies - 16 through 26 (of 26 total)
  • Anonymous User 5862444

    (@anonymized-5862444)

    Hi

    Thanks a lot for answering.

    I am going to add this to my code as soon as possible!

    Thanks!

    derherrkohler

    (@derherrkohler)

    add_filter('wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_disable_free', 10, 4 );
    function wpo_wcpdf_disable_free( $condition, $order, $status, $template_type  ) {
    	// use $template type to make rules specific to the document
    	// ('packing-slip', 'invoice', 'proforma' or 'credit-note')
    
    	$order_total = $order->get_total();
    	if ( $order_total > 0 ) {
    		return $condition;
    	} else {
    		// free order, don't generate pdf
    		return false;
    	}
    }

    This code is wunderful, BUT there is a little problem with the generated PDFs left.
    The invoice number is always zero.

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Herr Kohler,
    This code doesn’t change anything to the invoice number, it only disables the attachment of invoices for free orders.
    You should be able to confirm this by removing this filter and regenerating an invoice.

    If the invoice number is always zero, I suspect something else is going on. Do you have any other filters for pdf invoices?

    Ewout

    Thank you for providing this workaround. I would be very happy to see this as an option in a next release.

    Plugin Contributor Ewout

    (@pomegranate)

    @blarg, I added this to the Gerenal settings in the last version (1.5.8)

    If you have a bit of time, I’d really appreciate it if you can leave me a review here!

    Hi Ewout,

    I need the same as the original poster: how can I avoid generating invoice for orders that are cost-free? (total = 0)

    Is there an hook I can use?

    Thanks

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Dabesa,
    As noted in the last post above yours: You can find this option in the General settings tab, no need for a hook or custom code. ?? (although the wpo_wcpdf_custom_attachment_condition filter still works).

    Let me know if you have any other questions!

    Ewout

    Hi Ewout,

    I’m aware of that option, but the behavior is different.
    I have that enabled, and the invoice is rightly not attached to the email, but it’s still generated and numbered.

    Example:
    – I’ve invoice 2015-10 with total $100;
    – I create a new order with total 0;
    – The buyer won’t receive the invoice by email, but in Woocommerce->Orders I see that the invoice is created with number 2015-11;

    I need to bypass the invoice creation or set the invoice number to 0 if the total is 0.

    Thanks!

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Dabesa,
    I have no explanation for this. The invoice number is ONLY generated when an invoice is created, and this happens ONLY when it is attached to the email, or when an admin (or possibly the customer, depending on your my-account settings) presses the Invoice button. See invoice numbers explained for more information.
    Are you using any other filters or hooks to create the invoice?

    Ewout

    Hi Ewout,
    Can you point me out which file/function to check for this?
    Can be another plugin triggering that?

    Thanks!

    Plugin Contributor Ewout

    (@pomegranate)

    I have nothing specific for you to check, other than what you (or your developer) may have added to functions.php yourself. I do not know of any plugins triggering the invoice creation.
    Another possibility is that you are using a filter that uses the order number as invoice number (as explained in the link from my previous post). Is this number in sync with the ‘next invoice number’ setting?

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘Don't increment invoice number on cost-free product’ is closed to new replies.