Viewing 13 replies - 1 through 13 (of 13 total)
  • Same problem here!!!

    What is the solution?

    Thanks.

    Plugin Contributor Ewout

    (@pomegranate)

    For anyone else with the same problem, the next snippet will print the order notes for you. Note that it filters out only the customer notes, not the private notes. Simply remove the if ( get_comment_meta ... statement you you want to display the private notes too.

    <?php
    $args = array(
    	'post_id' 	=> $wpo_wcpdf->export->order->id,
    	'approve' 	=> 'approve',
    	'type' 		=> 'order_note'
    );
    
    remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
    
    $notes = get_comments( $args );
    
    add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
    
    if ( $notes ) {
    	foreach( $notes as $note ) {
    		if ( get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ) {
    			?>
    				<div class="note_content">
    					<?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
    				</div>
    			<?php
    
    		}
    	}
    }
    ?>

    Where does the snippet go? Can you clarify? Thanks.

    Plugin Contributor Ewout

    (@pomegranate)

    The snippet goes into your custom template, exactly where you’d like to display the notes.

    Add Refund to Invoice.

    Hi there,

    how do i add refunds to the invoice? With WC 2.2 refunds are now enabled..i want to update refunded orders with pdf new invoices to keep bookkeeping up to date…

    thanks,
    phil

    Plugin Contributor Ewout

    (@pomegranate)

    The latest version of the plugin includes a shorthand function to print order comments! From the FAQ:

    How can I display order notes in the invoice or packing slip?
    First, you need to create a custom template following instructions from the first item in this FAQ. Then place the following snippet where you would like the order notes to appear:

    <?php $wpo_wcpdf->order_notes(); ?>

    if you want to display all order notes, including the (private) admin notes, use:

    <?php $wpo_wcpdf->order_notes('all'); ?>

    Thanks!!! It works well!!!

    @ewout,

    Thanks for this little guide! How would I do this is I gave products a specific product tag and I wanted to display that instead of a custom note?

    I’m assuming I would just have to change up a few variables, but I’m still pretty new to Woocommerce. I’d really appreciate if you could show me what I would have to change in that script above to make it display the product tag I have associated with my products.

    Thanks again!

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Seth,
    You can get the product tags with the following code:

    <?php echo strip_tags( $item['product']->get_tags() ); ?>

    Please note that you can only do this below each product in the order items table. You could also do this without creating a custom template, by using one of the PDF template action hooks:

    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_product_categories', 10, 3 );
    function wpo_wcpdf_show_product_categories ( $template_type, $item, $order ) {
        // get a comma separated list of tags (tag links stripped)
        $tags = strip_tags( $item['product']->get_tags() );
        echo '<div class="product-tags">Tags: '.$tags.'</div>';
    }

    Hope that helps!

    Ewout

    Ewout I tried inserting that bit of code into the email template like so…

    <?php
    /**
     * Customer processing order email
     *
     * @author 		WooThemes
     * @package 	WooCommerce/Templates/Emails
     * @version     1.6.4
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    ?>
    
    <?php do_action('woocommerce_email_header', $email_heading); ?>
    
    <p><?php _e( "Your order has been received and is now being processed. Your order details are shown below for your reference:", 'woocommerce' ); ?></p>
    
    <?php do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text ); ?>
    
    <h2><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></h2>
    
    <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
    	<thead>
    		<tr>
    			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'woocommerce' ); ?></th>
    			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
    			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'woocommerce' ); ?></th>
    		</tr>
    	</thead>
    	<tbody>
    		<?php echo $order->email_order_items_table( $order->is_download_permitted(), true, $order->has_status( 'processing' ) ); ?>
    	</tbody>
    	<tfoot>
    		<?php
    			if ( $totals = $order->get_order_item_totals() ) {
    				$i = 0;
    				foreach ( $totals as $total ) {
    					$i++;
    					?><tr>
    						<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
    						<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
    					</tr><?php
    				}
    			}
    		?>
    	</tfoot>
    </table>
    
    <?php
    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_product_categories', 10, 3 );
    function wpo_wcpdf_show_product_categories ( $template_type, $item, $order ) {
        // get a comma separated list of tags (tag links stripped)
        $tags = strip_tags( $item['product']->get_tags() );
        echo '<div class="product-tags">Tags: '.$tags.'</div>';
    }
    ?>
    
    <?php do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text ); ?>
    
    <?php do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text ); ?>
    
    <?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
    
    <?php do_action( 'woocommerce_email_footer' ); ?>

    It did not end up showing the product tag in the email I received. Do I need to place it in the template differently?

    Also that link to PDF templates did not work

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Seth,
    I think there’s been a misunderstanding. This forum is not about WooCommerce, but about an add on for WooCommerce that creates PDF Invoices & Packing Slips. The code won’t work in emails!

    The first code is for use directly in a custom PDF template, the second should be put in your themes functions.php. Here’s the correct link to the documentation (it was missing http): PDF template action hooks

    For questions about WooCommerce, you should go to the WooCommerce forum (or WooThemes support if you have bought a paid extension from them).

    Good luck!
    Ewout

    Ah yes. There has been a misunderstanding. I apologize for that, and I did not mean to derail the thread at all. I will try over in the WooCommerce forum.

    I would think for something that seems like a common use i.e. use a product tag then display that on a receipt. That there would be some guides to follow, but I have not been able to find anything on this. 🙁

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to add Customer/Order notes?’ is closed to new replies.