WooCommerce TM Extra Product Options #2
Selling products with custom options? Engraving, gift wrap, size, color?
TM Extra Product Options plugin adds these choices. Standard exports ignore them.
Here’s how to export each option as its own row.
What this code does
Takes each product option. Turns it into a separate row. Shows:
- TM pos (position/order of the option)
- TM name (what the option is called)
- TM value (what customer selected)
- TM price (how much it cost)
- TM quantity (how many)
- TM name_value (combined name and value)
The complete code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
// add each option as product row class WOE_add_TM_cols{ var $tm_cols = array( 'pos','name','value','price','quantity','name_value'); function __construct() { add_filter('woe_get_order_product_fields',array($this,'add_product_fields') ); add_filter('woe_fetch_order_products', array($this,'fill_tm_cols') ,10, 5); } function add_product_fields($fields) { foreach($this->tm_cols as $tm_col) { $fields['tm_field_'.$tm_col] = array('label'=>'TM '.$tm_col,'colname'=>'TM '.$tm_col,'checked'=>1); } return $fields; } function fill_tm_cols($products, $order, $labels, $format,$static_vals) { $new_products = array(); foreach( $products as $item_id=>$product) { $item_meta = get_metadata( 'order_item', $item_id ); $pos = 1; if( isset($item_meta["_tmcartepo_data"]) AND is_array($tmfields = maybe_unserialize($item_meta["_tmcartepo_data"][0])) ) { foreach($tmfields as $tm_field) { $new_product = $product; $tm_field['pos']= $pos++;//set fake field $tm_field['name_value'] = $tm_field['name'] . ':' .$tm_field['value']; // fill TM columns foreach($this->tm_cols as $tm_col) { if( isset($new_product['tm_field_'.$tm_col])) $new_product['tm_field_'.$tm_col] = $tm_field[$tm_col]; } //add each option as new product! $new_products[] = $new_product; } } if( isset($item_meta["_tmcartfee_data"]) AND is_array($tmfields = maybe_unserialize($item_meta["_tmcartfee_data"][0])) ) { foreach($tmfields[0] as $tm_field) { $new_product = $product; $tm_field['pos']= $pos++;//set fake field $tm_field['name_value'] = $tm_field['name'] . ':' .$tm_field['value']; // fill TM columns foreach($this->tm_cols as $tm_col) { if( isset($new_product['tm_field_'.$tm_col])) $new_product['tm_field_'.$tm_col] = $tm_field[$tm_col]; } //add each option as new product! $new_products[] = $new_product; } } if($pos==1) //nothing added - just copy product as is $new_products[] = $product; } return $new_products; } } new WOE_add_TM_cols(); |
Setup steps
- Copy the entire code block
- Paste into your theme’s
functions.php - Go to Advanced Order Export for WooCommerce
- Create or edit an export profile
- Open Setup Fields → Products
- You’ll see TM fields. Check the ones you need
- Save and test on an order with TM options
What your export looks like
Order with one product and two options:
| Product | TM name | TM value | TM price | TM quantity |
|---|---|---|---|---|
| T-Shirt | Size | Large | $0.00 | 1 |
| T-Shirt | Color | Blue | $0.00 | 1 |
| T-Shirt | Gift Wrap | Yes | $5.00 | 1 |
Each option gets its own row. Same product appears multiple times.
Real examples
Engraved necklace:
| Product | TM name | TM value | TM price |
|---|---|---|---|
| Pendant | Engraving Text | “Love Mom” | $10.00 |
| Pendant | Chain Length | 18 inch | $0.00 |
Pizza order:
| Product | TM name | TM value | TM price | TM quantity |
|---|---|---|---|---|
| Large Pizza | Topping | Pepperoni | $2.00 | 1 |
| Large Pizza | Topping | Mushrooms | $1.50 | 1 |
| Large Pizza | Crust | Thin | $0.00 | 1 |
When you need this
You sell customizable products. Need to track each option separately.
Your fulfillment team needs to see engraving text, sizes, or colors.
You calculate costs per option. Need breakdown by option type.
You analyze which options sell best. Need option-level data.
How it works
TM Extra Product Options stores selections in order item meta:
_tmcartepo_datafor regular options_tmcartfee_datafor fee-based options
The code reads both. Extracts each option. Creates a new product row per option.
Common mistake
The code duplicates products. One product with 3 options becomes 3 rows.
Your row count increases dramatically. Export files get larger.
Test on a single order first. Understand the output.
Empty TM columns?
No TM options on this product. Or TM plugin not active.
The code simply copies the original product row. TM columns stay empty.
Pro tip
Need only certain options? Filter by $tm_field['name']. Skip unwanted options.
Need option totals? Add the TM price column. Sum in your spreadsheet.
Real talk
TM Extra Product Options is powerful. Customers can build complex products.
But standard exports lose all that detail. This code recovers it.
Your production team gets clear instructions. “Engrave ‘Love Mom’ on pendant” appears in its own row. No ambiguity. No back-and-forth emails.