Added custom fields Gift Message and FedEx Shipping to printouts
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 24 Jul 2015 18:10:22 +0000 (14:10 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 24 Jul 2015 18:10:22 +0000 (14:10 -0400)
functions.php

index 4a97868..917912c 100755 (executable)
@@ -192,6 +192,25 @@ function tm_added_checkout_fields_email( $keys ) {
         return $keys;
 }
 
+// Add custom fields to order printouts
+function add_custom_fields_to_order_printout( $fields, $order ) {
+    $new_fields = array();
+    if( get_post_meta( $order->id, 'Gift Message', true ) ) {
+        $new_fields['Gift Message'] = array( 
+            'label' => 'Gift Mesage',
+            'value' => get_post_meta( $order->id, 'Gift Message', true )
+        );
+    }
+    if( get_post_meta( $order->id, 'FedEx Shipping', true ) ) {
+        $new_fields['FedEx Shipping'] = array( 
+            'label' => 'FedEx Shipping',
+            'value' => get_post_meta( $order->id, 'FedEx Shipping', true )
+        );
+    }
+    return array_merge( $fields, $new_fields );
+}
+add_filter( 'wcdn_order_info_fields', 'add_custom_fields_to_order_printout', 10, 2 );
+
 // Add a $1.00 handling fee to all orders.
 add_action( 'woocommerce_cart_calculate_fees','endo_handling_fee' );
 function endo_handling_fee() {