• Resolved AndieDK

    (@andiedk)


    Hello,

    How can it be possible to show the product tags on the print invoice? Right now i using the “tags” as a product location in our warehouse, but we need to have it showed first on each line on the printed invoice. Is there any there can help?

    Thank you!

Viewing 1 replies (of 1 total)
  • Plugin Author Vishal Kothari

    (@ashokrane)

    Hi @andiedk,

    You can use the below code to add product tags just below the product name in your invoice.

    add_filter( 'wcdn_order_item_fields', 'display_product_tags', 10, 2 );
    function display_product_tags( $fields, $product ) {
    	$fields_new = $fields;
    	$i = count( $fields_new ) + 1;
    	$tags = get_the_terms( $product->id, 'product_tag' );
    	if( isset( $tags ) && count( $tags ) > 0 && $tags !== false ) {
    		$fields_new[ $i ][ 'label' ] = 'Tags: ';
    		foreach ($tags as $key => $value) {
    			$fields_new[ $i ][ 'value' ] .= $value->name . ', ';
    		}
    		$fields_new[ $i ][ 'value' ] = substr( $fields_new[ $i ][ 'value' ], 0, strlen( $fields_new[ $i ][ 'value' ] ) - 2 );
    	}
    	return $fields_new;
    }

    This is how it would appear: https://screencast.com/t/lwAGqxn1

    If there are no tags, then nothing would display there.

    I hope this helps.

    :Vishal

Viewing 1 replies (of 1 total)
  • The topic ‘Show product tags on print invoice’ is closed to new replies.