Support » Plugin: WooCommerce PDF Invoices & Packing Slips » How to attach invoice to custom woocommerce status ?

  • Resolved gore.m

    (@gorem)


    Hello,

    Im sending “processing order” email to customer twice, first in original form and than again tweaked, after order has changed status to my custom status “order-accepted”.
    Is it possible to attach invoice to that last email (processing order + order accepted)?

    Thanks you

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

    (@pomegranate)

    Hi! Could you elaborate a little bit more on the ‘tweaking’ you did? Is it the same email with additional actions/filters or is it actually a separate email template for that ‘order-accepted’ status? Do you mean you want to only attach the PDF to the ‘processing’ email when it has the ‘order-accepted’ status rather than the actual ‘processing’ status?

    Hi and thanks you for your reply.

    I needed new order status order-accepted, but I didnt want to construct new email, processing order email has enough I need, so I tweaked subject and heading and triggered it again to new order status, but I didnt realise, that this scenario wont be shown in your “PDF attach to section”.

    So… You are right I want to attach the PDF to the ‘processing’ email when it has the ‘order-accepted’ status.
    Is it possible?

    Plugin Author Ewout

    (@pomegranate)

    I see, you can control this with the wpo_wcpdf_custom_attachment_condition filter. Here’s an example (untested):

    
    add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_processing_accepted_email', 100, 4 );
    function wpo_wcpdf_processing_accepted_email( $condition, $order, $email_id, $document_type ) {
    	// disable attachment of the invoice to the processing email if the status is not order-accepted
    	if ( $document_type == 'invoice' && $email_id == 'customer_processing_order' && $order->get_status != 'order-accepted') {
    		return false; 
    	} else {
    		return $condition;
    	}
    }
    

    It is not working, invoice is not attached in both emails (even if attach to “Processing order” is checked or not) 🙁

    Plugin Author Ewout

    (@pomegranate)

    I don’t know the specifics of your setup, so I’m afraid there’s not much I can do for you… In any case, you do need to have the attachment for the processing email enabled in the settings.
    There was a small typo in the filter that I think may have caused it not to work, I put $order->get_status instead of $order->get_status(). Can you try with that fix?

    
    add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_processing_accepted_email', 100, 4 );
    function wpo_wcpdf_processing_accepted_email( $condition, $order, $email_id, $document_type ) {
    	// disable attachment of the invoice to the processing email if the status is not order-accepted
    	if ( $document_type == 'invoice' && $email_id == 'customer_processing_order' && $order->get_status() != 'order-accepted') {
    		return false; 
    	} else {
    		return $condition;
    	}
    }
    

    Super cool! It is working, thanks you very much.
    I have to say, you have best plugin support ever .-)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to attach invoice to custom woocommerce status ?’ is closed to new replies.