Remove Random Metas from PDF Invoice and Packing Slips

This snippet is designed to remove all the extra order meta data that may be showing on your PDF invoices. Many plugins will create extra order metas, for example I use Yith Product Add Ons and those order metas I absolutely need to display. So this snippet gives us the ability to hide any superfluous order metas that are showing on the PDF invoice (I choose to automatically send the customer a PDF invoice attached to their order confirmation email, which is why this matters to me).

As always, this is either added to your Child Theme’s functions.php file, or consider using the My Custom Functions Pro plugin to manage and organize all your snippets.

add_action( 'before_wcmp_pdf_invoice_template_item_meta', 'variation_product_extra_variation_fields' , 10 , 3 );

function variation_product_extra_variation_fields ( $hook_data_pdf_type, $item, $hook_data_order ) {
   $hidden_order_itemmeta = apply_filters(
    'wcmp_vendor_dash_hidden_order_itemmeta', array(
       'Sold By',
   if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : 
      foreach ( $meta_data as $meta_id => $meta ) :
         if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) {
         <li class="item-meta" style="list-style: none; padding-left: 2em; min-width: 60%;"><span><?php echo wp_kses_post( $meta->display_key );  ?>:</span> <span><?php echo wp_kses_post( force_balance_tags( $meta->display_value ) ); ?></span></li>


Tested and working on Woocommerce 4.6.1, WCMp 3.5.10

Is this no longer relevant or not working? Please let us know in the comments!

Comments on this post

Your email address will not be published. Required fields are marked *