• Resolved francescor

    (@francescor)


    Hi, is it possible to disable the invoice generation if a specific payment method is used?

    Thanks

    • This topic was modified 7 years, 11 months ago by francescor.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! Yes, you can use a filter for that:

    
    add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_exclude_payment_method', 100, 4 );
    function wpo_wcpdf_exclude_payment_method( $condition, $order, $status, $document ) {
    	$payment_method = get_post_meta( $order->id, '_payment_method', true );
    	if ( $payment_method == 'cheque' ) {
    		return false;
    	} else {
    		return $condition;
    	}
    }
    

    Read this if you haven’t worked with code snippets/filters like this before: How to use filters.

    Hope that helps!
    Ewout

    Thread Starter francescor

    (@francescor)

    Thank you, I tried the script. The invoice does not get sent to the user via mail but it still gets generated and it is downloadable by the user from his control panel, so the problem did not get solved.

    Moreover – but I might need to open another thread for this – sometimes the invoices get generated in hungarian (while they should be in italian).

    Could you please help?

    Thanks

    Francesco

    Plugin Contributor Ewout

    (@pomegranate)

    Hi francesco,
    You can control the visibility of the invoice button in the General settings tab.

    Are you using WPML or Polylang? If so, you need the Professional extension for full multilingual support (other multilingual plugins are not currently supported).

    Ewout

    • This reply was modified 7 years, 10 months ago by Ewout.
    Thread Starter francescor

    (@francescor)

    The invoice has not to be generated if a specific payment method is used. Is this possibile? If it gets generated there will be a document with a progressive number that we will have to account for in some way and that won’t work for us.

    I am not using any multi-language plugin at the moment. To be precise WPML is installed but not active. Anyway the invoices must be in the default language for now (that is not hungarian).

    Please let me know

    Thanks

    Francesco

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Francesco,
    Yes, that’s certainly possible with the above script. Just make sure you have configured the plugin so that the user can only see the download link in My Account if an invoice was already created. Note that the admin (=shop manager) buttons will still be visible!

    I have no explanation for why the invoices are in hungarian, although with WP4.7 it is possible to change the language of the admin per user, and this also changes the language of the invoice. I cannot do anything about this.

    If you are considering WPML, I recommend looking at Polylang too. Polylang is much more stable in my experience and also ‘speaks WPML’, which means that most plugins that are WPML compatible are also Polylang compatible.

    Good luck!
    Ewout

    Thread Starter francescor

    (@francescor)

    It works, thanks. The buttons that generate the invoices were misleading me. I simply hid them now. I did not understand that they actually generate invoices that do not exist at all.

    Plugin Contributor Ewout

    (@pomegranate)

    Great, glad to hear that’s resolved!

    Ewout

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Disable invoice by payment method’ is closed to new replies.