How to attach the packing slip to a specific email type?

Add below filter to your (child) themes functions.php in order to attach the packing slip to a specific email type. Below example will add the packing slip to the New Order email.

function attach_packing_slip_to_email( $attachments, $status, $order ) {
	// only attach to emails with WC_Order object.
	if ( ! $order instanceof WC_Order ) {
		return $attachments;
	}

	if ( 'new_order' !== $status ) {
		return $attachments;
	}

	$order_id     = BEWPI_WC_Order_Compatibility::get_id( $order );
	$packing_slip = new BEWPI_Packing_Slip( $order_id );
	$full_path    = $packing_slip->generate();

	$attachments[] = $full_path;

	return $attachments;
}
add_filter( 'woocommerce_email_attachments', 'attach_packing_slip_to_email', 99, 3 );

Still need help? Contact Us Contact Us