Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Choose whether to send the invoice

  • Resolved lowick

    (@lowick)


    Hello,

    Is there a way to check with a condition to send the invoice by email to the customer?

    So be able to activate or deactivate the invoice sending by email.

    Thank you forwards

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ewout

    (@pomegranate)

    Hi! What kind of condition would you like to set?
    The only condition you can set via the plugin settings is based on the order status emails. So if you want to only send the invoice for orders that are paid, you can set it to only attach to “Processing” and/or “Completed” emails. If you need more fine-grained control there’s a filter you can use: wpo_wcpdf_custom_attachment_condition. Here are two examples:
    Disable invoice for certain categories
    Disable invoice for certain payment methods

    Hope that helps!
    Ewout

    Thank you for your answer 🙂

    I wanted to know if there was way to send an invoice only if a specific field is completed in the checkout form.

    ex: If the name of the company is completed, send the invoice with the completed email.

    Plugin Author Ewout

    (@pomegranate)

    Sure, here’s an example that checks if the billing company field is filled in:

    
    add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_invoice_attachment_condition', 100, 4 );
    function wpo_wcpdf_invoice_attachment_condition( $condition, $order, $status, $template_type ) {
        // only apply condition to invoices
        if ($template_type == 'invoice') {
            $billing_company = $order->get_billing_company();
            // do not attach invoice if billing company is not filled in
            if (empty($billing_company)) {
                $condition = false;
            }
        }
    
        return $condition;
    }
    

    Ewout

    Ok Thank you again

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Choose whether to send the invoice’ is closed to new replies.