• Resolved pipoulito

    (@pipoulito)


    Hi,

    I need to add code (do something depending on payment method) when you send the email on Completed order.
    Could you please tell me where is located the function, in witch php file ?
    thanks a lot

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

    (@pomegranate)

    Hi! The PDF Invoices & Packing Slips plugin does not send emails, that’s WooCommerce territory.
    There’s an hook that you can utilize to execute a function when the order is completed, woocommerce_order_status_completed.
    To make this more versatile, you can use the action that is triggered for each status change, woocommerce_order_status_changed. Here’s an example:

    
    add_action( 'woocommerce_order_status_changed', 'woocommerce_order_status_changed_action', 10, 3 );
    function woocommerce_order_status_changed_action( $order_id, $old_status, $new_status ) {
        if( $new_status == "completed" ) {
            $order = wc_get_order( $order_id );
            $payment_method = $order->get_payment_method();
            // Do your magic here
        }
    }
    

    This is beyond the scope of this free plugin support, but hopefully the above will get you on track with this!

    Ewout

    Thread Starter pipoulito

    (@pipoulito)

    Hi,

    thanks a lot ! Actually i added this code in your function attach_pdf_to_email to not send pdf if the payment method is cheque and status is completed , and it seems to work.

    if ($order->get_payment_method()==’cheque’ && $order->has_status( ‘completed’ ) ) {return;}

    Plugin Contributor Ewout

    (@pomegranate)

    That’s not a good idea, because those changes will be overwritten with the next plugin update. You can use the wpo_wcpdf_custom_attachment_condition filter.
    More information:
    https://wordpress.org/support/topic/choose-whether-to-send-the-invoice/

    Thread Starter pipoulito

    (@pipoulito)

    Great !!! many thanks !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Email Order completed custom’ is closed to new replies.