• Resolved GottaGetEm

    (@gottagetem)


    Hi there,

    We are looking to attach PDF files to order emails for specific products in specific categories. We have searched the web and found various custom options and plugins but more to do with packing slips or invoices. These were more global options rather than breaking down to a specific category or product.

    We were hoping posting here could guide us in the right direction. Any advice would be appreciated. If this is the wrong place to post this I apologize. If someone points to the right place to post I will do that.

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey,

    You can use the following hook to send PDFs as an attachment to an order mail

    add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
    function attach_terms_conditions_pdf_to_email ( $attachments , $id, $object ) {
    	$your_pdf_path = get_template_directory() . '/terms.pdf';
    	$attachments[] = $your_pdf_path;
    	return $attachments;
    }

    And with part of this code you can see if an order contains a specific product id

    /**
     * @snippet       WooCommerce: Check if Product ID is in the Order
     * @how-to        Get CustomizeWoo.com FREE
     * @author        Rodolfo Melogli
     * @compatible    WooCommerce 3.8
     * @donate $9     https://businessbloomer.com/bloomer-armada/
     */
        
    add_action( 'woocommerce_thankyou', 'bbloomer_check_order_product_id' );
       
    function bbloomer_check_order_product_id( $order_id ){
    $order = wc_get_order( $order_id );
    $items = $order->get_items(); 
    foreach ( $items as $item_id => $item ) {
       $product_id = $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id();
       if ( $product_id === XYZ ) {
           // do something
       }
    }
    }

    So if you combine both you can certainly get what you want.

    Regards

    Thread Starter GottaGetEm

    (@gottagetem)

    @crslz Thank you for your time and the suggestion.

    I will be testing within the hour. I will post here how it goes.

    Thank you again.

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. Feel free to start a new thread if you have any further questions!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How To Send Emails With PDF For Specific Product and Category’ is closed to new replies.