Not working with woocommerce_email_attachments filter anymore
-
Hey there,
Since the last update it looks like the plugin interferes with the woocommerce_email_attachments filter I use to add some manual attachments to some products. My code in functions.php is no longer executed when “WooCommerce PDF Invoices & Packing Slips” plugin is activated:
add_filter( 'woocommerce_email_attachments', 'add_woocommerce_attachments_for_certain_product', 10, 3 ); function add_woocommerce_attachments_for_certain_product ( $attachments, $email_id, $email_order ){ $product_id1 = 1; $product_id2 = 2; if( $email_id === 'customer_completed_order' ){ $order = wc_get_order( $email_order ); $items = $order->get_items(); $temp = false; foreach ( $items as $item ) { if ( $product_id1 === $item->get_product_id() ) { $attachments[] = get_stylesheet_directory() . '/special1.pdf'; // Child theme $temp = true; } if ( $product_id2 === $item->get_product_id() ) { $attachments[] = get_stylesheet_directory() . '/special2.pdf'; // Child theme $temp = true; } } if ( $temp === false) { $attachments[] = get_stylesheet_directory() . '/standard.pdf'; // Child theme } } return $attachments; }Is there a solution for this problem? I had to manually downgrade the plugin so that my store could continue to perform the desired functions.
Thanks in advance
Best regards
Ray
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘Not working with woocommerce_email_attachments filter anymore’ is closed to new replies.