Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter ticoocit

    (@ticoocit)

    First of all let me thank you for reaching me out @rynald0s.
    Previously I’ve created a custom plugin to get the billing_email, with the help of an user.
    So I managed to make this attached PDF work, adding the following code to the plugin:

    add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
    
    function attach_terms_conditions_pdf_to_email ( $attachments, $status , $order ) {
    	$allowed_statuses = array( 'customer_completed_order' );
    
    	if( isset( $status ) && in_array ( $status, $allowed_statuses ) ) {
    		$pdf_name = get_post_meta( get_the_id(), 'email_fatura', true );
    		$pdf_path = get_home_path() . '/Faturas/GestaoDespesas/' . $pdf_name;
    		$attachments[] = $pdf_path;
    	}
    
    	return $attachments;
    }

    This means, that it is going to look for post_meta – email_fatura (translated: email_invoice) and pass the value to pdf_name.
    So far it’s working good if I put some value on post_meta. But if I don’t it sends a file as well, called “GestaoDespesas”. But I don’t want that, if there is no value, it shouldn’t send anything.

    Can you please help me on that?

    Thank you in advance for your help.

    Best regards.

    • This reply was modified 3 years, 11 months ago by ticoocit.
    Thread Starter ticoocit

    (@ticoocit)

    Thanks you!! I’ll give it a check, absolutely! ??

    Thread Starter ticoocit

    (@ticoocit)

    @claudiosanches is totally fine! I should have noticed that was missing that part. ??

    So now it’s working perfectly. You mentioned about the “Plugin Name”, that what is stated on comment block is what the plugin is called on the plugins dashboard, is that right?

    Thank you so much! You see..
    1. You helped with my question
    2. You created a small plugin for me
    3. AND YOU THOUGHT ME HOW TO MAKE MY OWN PLUGIN WORKING!

    That is a lot more what I expected to learn!

    Thread Starter ticoocit

    (@ticoocit)

    I’ve tried what you told me, I activated the plugin, but the dashboard and the site doesn’t react very well as you can see:

    https://ibb.co/BnvyTXL

    https://ibb.co/9yWG5mg

    https://ibb.co/2MHk8pM

    Do you think it is better to edit with the Jetpack?

    Thank you so much for helping me!

    Thread Starter ticoocit

    (@ticoocit)

    Hi @claudiosanches,
    first of all, let me thank you for helping me on this.

    As you passed me the code, I don’t need skills on coding, right? ehehe ??

    [BEFORE EDIT]
    What I’m trying to understand is where I can paste that code? On the customer-completed-order.php, on editing woocoomerce?

    [EDIT]
    I got it! I paste it on class-wc-emails.php and it’s already functioning!!!!

    Thank you so much!!!That made my day!

    • This reply was modified 4 years ago by ticoocit.
    Thread Starter ticoocit

    (@ticoocit)

    Hi @alexmustin,

    that’s ok, I totally understand.
    I thought it would be something that I could edit on the plugin editor, that’s why I asked.

    I’ll wait then. ??

    Keep the good work.

Viewing 6 replies - 1 through 6 (of 6 total)