• Resolved marcateap

    (@marcateap)


    Hello. I am hoping to do something seemingly pretty simple. We have some extra information for our orders that lives in Order Items Meta and I’d like to simply display that info somewhere on our pdf invoice (preferably just below the item info). I’ve tried a code snippet that attempts to retrieve it by using get_meta(‘eap_course_data’) but this doesn’t seem to work. I must be missing something pretty simple but I’m not sure what it is. Any help or insight would be great. Thanks!

    See the meta here https://ibb.co/jZs2gyL

    • This topic was modified 5 months, 3 weeks ago by marcateap.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @marcateap:

    If this is an item custom meta, you could achieve it with the following code snippet:

    /**
    * PDF Invoices & Packing Slips for WooCommerce:
    * Display item custom fields after the item meta
    */
    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_product_custom_field', 10, 3 );
    function wpo_wcpdf_product_custom_field ( $template_type, $item, $order ) {
    if ( empty( $item['item'] ) ) return;
    // Replace "location" with the actual name
    $field_name = 'location';
    $location = $item['item']->get_meta( $field_name ) ?: $item['item']->get_meta( "_$field_name");
    if ( ! empty( $location ) ) {
    echo '<div class="product-location" style="font-size:7pt;margin-top:-5pt;">Location: ' . $location . '</div>';
    }
    }

    Otherwise, if it is a product custom meta, see some examples here: Displaying product custom fields

    Thread Starter marcateap

    (@marcateap)

    Thanks Yordan!

    That was all I needed! I was able to finagle the display of the required data based on your code snippet.

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