• Resolved falatoid

    (@falatoid)


    Hello, I would like to disable invoices for orders paid by cash on delivery (COD). Is there a way to generate invoices only for orders paid by card?

    Thank you so much!

    • This topic was modified 5 months ago by falatoid.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @falatoid,

    If you have the ​Professional extension, this can be configured right in the PDF invoices settings, in WooCommerce > PDF Invoices > Documents > Invoice > General > Disabled for:

    If you are only using the free main plugin, you can achieve this with the following code snippet:

    /**
    * PDF Invoices & Packing Slips for WooCommerce
    * Disable invoices for orders paid by Cash on Delivery (COD)
    */
    add_filter( 'wpo_wcpdf_document_is_allowed', function( $allowed, $document ) {
    if ( $order = $document->order ?? false ) {
    if ( $document->exists() ) {
    return $allowed;
    }
    // Apply this behavior only to the PDF Invoice
    if ( $document->type === 'invoice' ) {
    $payment_method = $order->get_payment_method();
    if ( $payment_method === 'cod' ) {
    $allowed = false;
    }
    }
    }
    return $allowed;
    }, 10, 2 );

    Let me know if you need anything else 😉

    Thread Starter falatoid

    (@falatoid)

    Thank you so much, it worked great!

    Have a nice day.

    I have the professional extension and this one works too but disables completely the option to create a COD invoice manually after the customer has paid. Is there any workaround to allow the manual creation later and avoid creating it automatically when goes to completed status?

    Thank you.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @muzankibutsuji,

    Instead of disabling the document altogether when the payment method is COD, you could skip the invoice automatic attachment only, using the same condition. This can be done with a code snippet too.

    Please contact us at [email protected] and I will write a code snippet for you as part of the premium support 😉

    Thanks Yordan, I just sent a message.

    Regards.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.