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
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/