Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Editing particular meta data formatting

  • Resolved printplaygames

    (@printplaygames)


    I’m doing some heavy customizing to my invoices for easier reading. I’m doing some color coding on various text items.

    I have one or two meta items and / or variations, that I would like color coded.

    So for example, if “blue” shows up in the color variation, I would like the background to be blue for that meta line.

    How can I do that? I already have a custom invoice built which I’m editing.

Viewing 1 replies (of 1 total)
  • Plugin Author Ewout

    (@pomegranate)

    The meta data in the invoice comes preformatted from WooCommerce (using the wc_display_item_meta function). This means that if you want to control the output you’ll have to do this at the WooCommerce end too, using the filter for that function. This will affect the meta included in the email sent you your customer too though, so you’ll have to either only apply it within the context of this plugin like so:

    
    add_action( 'wpo_wcpdf_before_html', function () {
    	add_filter( 'woocommerce_display_item_meta', 'woocommerce_display_item_meta_custom', 10, 3 )
    });
    add_action( 'wpo_wcpdf_after_html', function () {
    	remove_filter( 'woocommerce_display_item_meta', 'woocommerce_display_item_meta_custom', 10, 3 )
    });
    function woocommerce_display_item_meta_custom( $html, $item, $args ) {
    	# code...
    	return $html;
    }
    

    Or you’ll have to pull in specific meta data separately with wc_get_order_item_meta, e.g.

    
    <?php echo wc_get_order_item_meta( $item['item_id'], 'item_meta_key', true ); ?>
    

    This is quite advanced stuff though, and beyond what we can provide as free support. I hope you can work with the above information, good luck!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.