Snippets

Visser Labs Adding static Order Item fields to the Orders export type: individual

Updated by Michael Visser

File functions.php Modified

  • Ignore whitespace
  • Hide word diff
 <?php
-function custom_woo_ce_order_fields( $fields ) {
-
-	$fields[] = array(
-		'name' => 'order_items_static',
-		'label' => __( 'Order Items: Static Field', 'woo_ce' ),
-		'hover' => __( 'Custom Field within functions.php', 'woo_ce' )
-	);
-	return $fields;
-
-}
-add_filter( 'woo_ce_order_fields', 'custom_woo_ce_order_fields' );
-
 function custom_woo_ce_extend_order_items_individual( $order, $order_item ) {
 
 	$order->order_items_static = 'Static value';
Created by Michael Visser

File functions.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+function custom_woo_ce_order_fields( $fields ) {
+
+	$fields[] = array(
+		'name' => 'order_items_static',
+		'label' => __( 'Order Items: Static Field', 'woo_ce' ),
+		'hover' => __( 'Custom Field within functions.php', 'woo_ce' )
+	);
+	return $fields;
+
+}
+add_filter( 'woo_ce_order_fields', 'custom_woo_ce_order_fields' );
+
+function custom_woo_ce_extend_order_items_individual( $order, $order_item ) {
+
+	$order->order_items_static = 'Static value';
+	return $order;
+
+}
+add_filter( 'woo_ce_order_items_individual', 'custom_woo_ce_extend_order_items_individual', 10, 2 );
+?>
HTTPS SSH

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