• Resolved baetensl

    (@baetensl)


    Hi,

    I am looking for some code as described in the FAQ where some metadata is removed from the invoice.
    https://snipboard.io/StPIzx.jpg
    The add-on “kaartje” needs to be removed form the invoice.

    I contacted the add-on from woocommerce and they mentioned the data is saved in the table wp_woocommerce_order_items.

    The response from them:

    Okay, so as I mentioned the products purchased in the order are stored in the database table called wp_woocommerce_order_items: https://d.pr/i/IDI54n
    
    And then Product Add-Ons for these products are in another table called wp_woocommerce_order_itemmeta
    
    The meta_key is the same as addon name
    
    So in my case, I have a field called Gift Note, and the meta_key is also the same: https://d.pr/i/imXK8w
    

    Could you asssit me to hide this certain item from the order when the invoice is created?

    BR
    Louis

    • This topic was modified 4 years, 7 months ago by baetensl.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Bas Elbers

    (@baaaaas)

    
    /**
     * Hide order itemmeta on WooCommerce PDF Invoices' invoice template.
     *
     * @param array $hidden_order_itemmeta itemmeta.
     *
     * @return array
     */
    function bewpi_alter_hidden_order_itemmeta( $hidden_order_itemmeta ) {
        $hidden_order_itemmeta[] = 'Gift note';
        // end so on..
        return $hidden_order_itemmeta;
    }
    add_filter( 'bewpi_hidden_order_itemmeta', 'bewpi_alter_hidden_order_itemmeta', 10, 1 );
    

    According to WooCommerce, above filter should hide the itemmeta.

    Thread Starter baetensl

    (@baetensl)

    Thanks for the reply!

    The following code works in order to hide the data on the order page :

    add_filter( 'woocommerce_hidden_order_itemmeta', 'hide_my_item_meta' );
    
    /**
     * Hiding item meta
     * 
     * @param array $hidden_meta Array of all meta data to hide.
     *
     * @return array
     */
    function hide_my_item_meta( $hidden_meta ) {
      
      // Let's hide the meta 'kaartje'.
      $hidden_meta[] = 'Kaartje (€1,00)';
      
      return $hidden_meta;
    }

    I am however not able to get this working on the plugin.
    Can you assist further?
    Do I need to look at the template code in order to get the code working?

    BR.

    Plugin Author Bas Elbers

    (@baaaaas)

    Create a custome template and add this to the CSS. It will hide the item meta.

    .wc-item-meta {
    display: none;
    }
    • This reply was modified 4 years, 6 months ago by Bas Elbers.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove woocommerce product add on from invoice’ is closed to new replies.