Title: Adding custom field data
Last modified: August 21, 2016

---

# Adding custom field data

 *  Resolved [Brendavo](https://wordpress.org/support/users/successful-life/)
 * (@successful-life)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-field-data/)
 * Hi.
 * First of all, you have a very nice plugin.
 * I am right now building a custom template to my websites / business needs, but
   i am a bit of stuck with one issue.
 * I use “woocommerce poor guys swiss knife plugin” to create custom fields on my
   checkout.
    I have 3 fields:
 * 1. Specifies Shipping Method ( radio buttons ) ( field ID=billing_piegadatajs)
   
   2. Select List of addresses for shipping 1 ( field ID=billing_pastastacija ) 
   3. Select List of adresses for shipping 2 ( field ID=billing_pakomati )
 * Now, it is very important to show these 3 fields in the Invoice, because the 
   shipping method and address comes ONLY from these values. Not from the billing_address
   in wp.
 * How could i echo or show these 3 fields on the invoice ?
 * P.s. i have successfully added phone number etc to the invoice, because that 
   is a woocommerce field, tho i have a hard time figuring out how to add these 
   custom fiels.
 * [https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-field-data/#post-4729928)
 * Hello Brendavo,
    The following code (also mentioned in [this thread](http://wordpress.org/support/topic/add-fields-in-the-simple-template-from-woocommerce-checkout-manager?replies=13))
   should retrieve your custom fields:
 *     ```
       <?php
       $billing_piegadatajs = get_post_meta($wpo_wcpdf->export->order->id,'_billing_piegadatajs',true);
       if (isset($billing_piegadatajs)) {
       	echo $billing_piegadatajs;
       }
       ?>
       ```
   
 * Note the leading underscore for the field name in the first line!
    The same code
   can be used for all three fields, just replace the field & variable names.
 *  Thread Starter [Brendavo](https://wordpress.org/support/users/successful-life/)
 * (@successful-life)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-field-data/#post-4729998)
 * Hello Ewout.
 * Thank you very much for your assistance. Your code helped me to get all 3 fields
   showing up on the invoice.
 * May i ask how to show the product image in the invoice or slip?
    My website will
   also do wholesale, so i know from experience, that an p-slip or invoice without
   product images is a very big pain in the ***, if there are dozens of products
   on it and only names / sku’s.
 * I would really appreciate it.
 * With Regards
 *  [ulihake](https://wordpress.org/support/users/ulih/)
 * (@ulih)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-field-data/#post-4730003)
 * Glad that you found a solution, Brendavo. I actually checked another plugin with
   nearly the same name. Thanks for clarifying this, Ewout. I will check your plugin
   this weekend.
 * If you have product thumbnails attached (does not work necessarily for variations
   this way!) you can use something like this, Brendavo:
 *     ```
       if ( '' != get_the_post_thumbnail( $id ) ) {
       	$thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), $size, false );
       	$thumburl = $thumb[0];;
       	echo '<img src="' . $thumburl . '" width="75" height="75"  />';
       }
       ```
   
 * For variations with no thumbnail this is a bit different as you have to retrieve
   the parent thumbnail… The width and height is optional. You can only set the 
   width or you can also use styles attaching a class or the style attribute.
 * Regards and good luck with your website.
    uh
 *  [ulihake](https://wordpress.org/support/users/ulih/)
 * (@ulih)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-field-data/#post-4730004)
 * PS on the last post: $id means the product_id in this case which should be available
   via the cart items listed in the invoice (the cart item id).
 *  [ulihake](https://wordpress.org/support/users/ulih/)
 * (@ulih)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-field-data/#post-4730012)
 * Forgot about the $size parameter… if you set it to an desired size like array(
   75,75) or a predefined thumbnail size identifier you will retrieve your image…
   Sorry for that. Normally you find the thumbnail predefinitions at the start of
   your theme’s function file.
 * uh

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding custom field data’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [ulihake](https://wordpress.org/support/users/ulih/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-field-data/#post-4730012)
 * Status: resolved