Viewing 15 replies - 1 through 15 (of 26 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello Martin,
    At the moment it’s not possible to prevent an invoice number to be generated for ‘free orders’.
    But perhaps it’s not an issue when the invoice number increments? You can still have this zero invoice in your administration (at least you don’t have to create an credit invoice or anything).

    I’m sorry I cannot help you with this!

    Ewout

    Thread Starter moberhammer

    (@moberhammer)

    Hi Ewout,

    thanks for your answear!

    Yes it’s unfortunately a little issue because our accounting has to book all invoices if I generate an invoice number for it.

    Regards,
    Martin

    Plugin Contributor Ewout

    (@pomegranate)

    You can however disable invoice creation for free orders altogether, with the following filter in your theme’s functions.php:

    add_filter( 'wpo_wcpdf_custom_email_condition', 'wpo_wcpdf_disable_free', 10, 3 );
    function wpo_wcpdf_disable_free( $condition, $order, $status ) {
    	$order_total = $order->get_total();
    	if ( $order_total > 0 ) {
    		return true;
    	} else {
    		// free order, don't generate pdf
    		return false;
    	}
    }
    Thread Starter moberhammer

    (@moberhammer)

    Hey,

    great that do the job! I though this filter would only prevent creating the pdf for email attachment. But it also prevents incrementing the invoice number!

    Thank you!!

    Regarts Martin

    Since last friday, this solution results in a broken checkout. The spin is turning infinitely. After removing this code from functions.php it worked again, but again makes invoices for free Downloads. Can you help?
    Thanks!

    Plugin Contributor Ewout

    (@pomegranate)

    Hi There,
    I cannot reproduce this on my own setup – just tried to checkout a free product on WooCommerce 2.2.7 and PDF 1.4.10 (version from friday), and it didn’t hang (didn’t attach either, as the filter dictates), so I’m not sure why this happens. Did it work normally before?

    On a sidenote, because we have released the Professional extension, there’s a new filter that replaces this one that can handle multiple different pdf types. The old one should still work (I tested with the one posted here), but you may try the new filter (delete the old one):

    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 one is also tested in my own setup, but because I’m not sure why the original one didn’t work on your setup I don’t know whether this one will!

    Plugin Contributor Ewout

    (@pomegranate)

    by the way, you may get a more descriptive error if you try to send the email manually from the backend (from the order actions in the right column on the order details page). You will need to enable WP_DEBUG first, which I advise to do on a test install rather than a live site.

    Hope that helps!
    Ewout

    Plugin Contributor Ewout

    (@pomegranate)

    Hi,
    I have a suspicion that this is also related to the issue in this thread (parent orders)
    They may be linked when you have disabled the address fields for free orders – then the plugin will look for the address in the parent order and possibly hang.

    Are you on WC2.1?
    Can you update to 1.4.12 to see if that fixes this for you?

    Thanks!
    Ewout

    THanks for your quick reply!
    Yes before Friday it worked well. It appears to me, that it only happens with non-logged new customers.
    I have updated and now I have Woocommerce 2.2.8 installed and your plugin at 1.4.12.
    I have deactivated the phone field from the Standard wc-form using woocommerce jetpack plugin.

    Now I have inserted the new filter as posted above and it happens again. Endless Spinning…

    Sorry I can’t produce a test Environment right now.

    Plugin Contributor Ewout

    (@pomegranate)

    Hi, send me an email at support@wpovernight.com, so I can try to help you fix this issue.

    Ewout

    Plugin Contributor Ewout

    (@pomegranate)

    By the way, how much memory do you have available for WordPress? You can see this on the status tab of the PDF plugin settings page.

    Update 1.4.14 solved the Problem an the code from above works fine again. Thank you!

    Anonymous User 5862444

    (@anonymized-5862444)

    Hi,

    Is this solution still ok?

    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;
    	}
    }

    Do you plan to add it as an included feature?

    This is very helpful for business that need only invoice with no zero price!

    Plugin Contributor Ewout

    (@pomegranate)

    Yes, this code should still work! I will consider including this as an option in the next version, as I can definitely see the use, but for now this filter should work perfectly.

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