WooCommerce Checkout Add-ons
Selling add-ons at checkout? Gift wrapping, donation options, or custom messages?
Standard exports show the fee amount. Not what the customer actually selected.
Here’s how to export the add-on values themselves.
What this code does
Exports checkout add-on selections as separate columns.
Example: You offer “Student Name”, “Student Grade Level”, and “Teacher Name” fields during checkout. Each becomes its own column.
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 |
// "Checkout Add-ons" plugin class WOE_Checkout_Addons_Mod { var $fields = array('Student Name','Student Grade Lavel','Teacher Name');// edit this line!! function __construct() { add_filter('woe_get_order_fields', array($this,'add_order_fields') ); add_action('woe_order_export_started', array($this,'get_fee_details') ); add_filter('woe_fetch_order_row', array($this,'fill_new_columns'), 10, 2); } function add_order_fields($fields) { foreach($this->fields as $pos=>$name) { $fields['fee_addon_'.$pos] = array('segment'=>'other','label'=>$name, 'colname'=>$name,'checked'=>1); } return $fields; } function get_fee_details($order_id) { $this->fee_data = array(); $order = new WC_Order($order_id); foreach($order->get_items("fee") as $item_id=>$item) { $pos = array_search($item['name'],$this->fields); if( $pos !== false) { $item_meta = $order->get_item_meta( $item_id ); $this->fee_data[$pos] = join(", ", $item_meta['_wc_checkout_add_on_value']); // many values? } } return $order_id; } // add new values to row function fill_new_columns($row,$order_id) { foreach($this->fields as $pos=>$name) { if(isset($row['fee_addon_'.$pos]) AND isset($this->fee_data[$pos]) ) $row['fee_addon_'.$pos] = $this->fee_data[$pos] ; } return $row; } } new WOE_Checkout_Addons_Mod(); |
Setup steps
- Edit the fields array to match your actual checkout add-ons:
|
1 |
var $fields = array('Gift Message', 'Delivery Date', 'Gift Wrap Color'); |
Use the exact names from your checkout add-ons.
- Copy the code into your theme’s
functions.php - Go to Advanced Order Export for WooCommerce
- Create or edit an export profile
- Open Setup Fields → Others
- You’ll see your add-on fields. Check the ones you need
- Save and test on an order with checkout add-ons
What your export looks like
| Order # | Order Total | Student Name | Student Grade Level | Teacher Name |
|---|---|---|---|---|
| 1001 | $150.00 | Sarah Johnson | 5th Grade | Ms. Davis |
| 1002 | $89.00 | Mike Chen | 3rd Grade | Mr. Wilson |
Each add-on field has its own column.
Real examples
Gift store:
|
1 |
var $fields = array('Gift Message', 'Gift Wrap Option', 'Delivery Date'); |
Restaurant ordering:
php
var $fields = array('Special Instructions', 'Allergy Notes', 'Pickup Time');
Event registration:
|
1 |
var $fields = array('Attendee Name', 'Dietary Restrictions', 'Emergency Phone'); |
When you need this
You sell personalized products. Need customer input in your export.
You run a restaurant. Need special instructions and allergy notes.
Your team fulfills orders manually. Need all add-on details in one place.
How it works
Checkout Add-ons stores customer selections as fee items. Each add-on becomes a fee line.
The code finds those fees. Matches them by name. Pulls the value from _wc_checkout_add_on_value meta. Puts each into its own column.
Common mistake
Field names must match exactly. “Student Name” won’t match “student name” or “StudentName”.
Check your checkout page. Copy the exact label text. Paste into the $fields array.
Empty columns?
Three things to check:
- Did the customer actually fill out that add-on?
- Does the add-on name match exactly?
- Is the Checkout Add-ons plugin active?
Multiple values for one add-on
Some add-ons allow multiple selections (checkboxes). The code joins them with commas.
Example: “Red, Blue, Green” in one cell.
Pro tip
Add more fields as needed. Just add new names to the $fields array.
|
1 |
var $fields = array('Field 1', 'Field 2', 'Field 3', 'Field 4', 'Field 5'); |
No other changes needed. The code handles any number of fields.
Real talk
Checkout Add-ons stores data differently than regular order meta. This code digs into fee items where the data lives.
Your fulfillment team gets clear instructions. No more “what did the customer write in that box?” Guesswork eliminated.