Add Product Meta Field to WooCommerce emails

With the placeholder “Product Meta Field” you can add a custom metafield from your WooCommerce products in the product table of every WooCommerce email.

WooCommerce Meta-Fields for products

In our example we use a custom field “product information”. This can be added by any third party plugin, your ERP software or manually.

Advanced Custom Fields

You can also use individual fields. The fields are stored in the database in the same way.

Add the placeholder to your email

Navigate to Settings -> Email Template -> WooCommerce and choose an email.

Click on one of the columns in the product table. In the drop-down list “Placeholder” you will see a new entry called Product Meta Field.

Click on it and replace the dots “” with your field name (in this example “productinformation“).

Save your template, return to the overview and see the result in the live preview at the bottom of the page.

8 Responses to “Add Product Meta Field to WooCommerce emails”

  1. Christophe Mathéi

    Hello,

    I installed your plugin, but the product meta is on one line. Is it possible to play on the meta layout?

    Thank you

    Christophe

    Reply
    • Hannes

      Hello,
      each of the placeholders [PRODUCT_META field=”…”] is just for one value. If your add a line break between them or add them to a list you have several ways to customize the entries.
      best regards, Hannes

      Reply
      • Christophe Mathéi

        Hello,

        Thank you for your reply

        I’m using your plugin with Bookingwp’s woocommerce appointment booking plugin. How can I know which meta field to use?

        Christophe

        Reply
        • Hannes

          As far as I know there’s no general overview to find out correct meta fields. The way I do this is:

          1. find out the ID of current order
          When you edit an order you can see it in the address bar of your browser

          2. find all meta fields in database
          open phpmyadmin (or any database tool of your choice), select the wp_postmeta table and filter all meta fields by post_id=XXX (the ID I found out in step 1)

          3. guess by key and value which one could be the right field.

          Reply
  2. Christophe Mathéi

    Hello,

    Thanks for your reply. The solution with the shortcode [PRODUCT_META field=”…”] does not work. So I’m trying to implement this code:

    add_filter( ‘haet_mail_placeholder_menu’, ‘add_mailbuilder_placeholder’ );
    add_filter( ‘haet_mail_order_placeholders’, ‘populate_mailbuilder_placeholder’, 10, 3 );

    function add_mailbuilder_placeholder( $placeholder_menu ){
    if( is_array( $placeholder_menu ) ){
    $placeholder_menu[] = array(
    ‘text’ => ‘Date’,
    ‘tooltip’ => ‘[date]’,
    );
    }

    return $placeholder_menu;
    }

    function populate_mailbuilder_placeholder( $order, $wc_order, $settings ){
    $order[‘date’] = ‘_appointment_start’;
    return $order;
    }

    I placed this code from function.php of my child theme it doesn’t work. I also tried with the code snippets plugin, it doesn’t work. What is my mistake?

    Reply
  3. Hannes

    The code looks good to me. Can you see the placeholder in the dropdown menu of the editor?

    Reply
    • Hannes

      Do you try to add it inside the products table or in a regular text block? (both have different placeholder menus)

      Reply

Leave a Reply