• Resolved muttly

    (@muttly)


    The products I have have up to 15 meta items that are displayed on the packing slip. I have a specific one that is duplicated. It must be duplicated to get 2 other plugins to work.

    The result of this is that there are 2 lines saying almost the same when the pdf is printed. One is called “Ticket Style”, the other is “Ticket Type”.

    Is it possible to have one of these not printed? I don’t mind which one but there is no need for both. It does not sound like a big deal but on most orders it means I have to use 2 printed pages instead of 1.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @muttly,

    You can unset specific item meta with a small code snippet:

    add_action( 'wpo_wcpdf_before_html', 'wpo_wcpdf_item_meta_remove_meta' );
    function wpo_wcpdf_item_meta_remove_meta() {
        add_filter( 'woocommerce_order_item_get_formatted_meta_data', 'woocommerce_order_item_meta_remove_meta', 10, 2 );
    }
    function woocommerce_order_item_meta_remove_meta( $formatted_meta, $item ) {
        $remove_meta = array( 'your_meta_key' );
        foreach ( $formatted_meta as $meta_id => $meta ) {
            if ( in_array( $meta->key, $remove_meta ) ) {
                unset( $formatted_meta[$meta_id] );
            }
        }
        return $formatted_meta;
    }

    In the $remove_meta array you can add every meta key you want to unset (comma separated). This code snippet should be placed in the functions.php of your child theme. If you haven’t worked with code snippets or functions.php please read this first: How to use filters

    Thread Starter muttly

    (@muttly)

    That works perfectly, thank you very much!!

    Just for anyone else using it, you wan to use the “Name” of the attribute you want to hide, not the “slug”.

    • This reply was modified 6 years, 5 months ago by muttly. Reason: Added note about using name rather than slug
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide specific product meta’ is closed to new replies.