Snippets

Visser Labs Adding multiple static Order fields to the Orders export type

Created by Michael Visser

File functions.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+function custom_woo_ce_order_fields( $fields ) {
+
+	$fields[] = array(
+		'name' => 'static_field_1',
+		'label' => __( 'Static Field #1', 'woo_ce' ),
+		'hover' => __( 'Static Field within functions.php', 'woo_ce' )
+	);
+	$fields[] = array(
+		'name' => 'static_field_2',
+		'label' => __( 'Static Field #2', 'woo_ce' ),
+		'hover' => __( 'Static Field within functions.php', 'woo_ce' )
+	);
+	return $fields;
+
+}
+add_filter( 'woo_ce_order_fields', 'custom_woo_ce_order_fields' );
+
+function custom_woo_ce_order( $order, $order_id ) {
+
+	$order->static_field_1 = 'Static value for Static Field #1';
+	$order->static_field_2 = 'Another static value for Static Field #2';
+	return $order;
+
+}
+add_filter( 'woo_ce_order', 'custom_woo_ce_order', 10, 2 );
+?>
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.