How to Access and Display Custom Checkout Field Data in WooCommerce
Content
If you're using the 'Checkout Field Editor (Checkout Manager) for WooCommerce' plugin, you've likely added some custom fields to your checkout page. A very common challenge users face is figuring out how to access the data submitted through those fields later on—whether it's for displaying in emails, invoices, a Google Sheet, or within your own custom code.
This guide will explain where this data is stored and provide the most common methods for retrieving it.
Where is the Custom Field Data Stored?
All fields created with the Checkout Field Editor plugin are saved as Order Meta Data in your WordPress database. This data is stored in the wp_postmeta table, with the order ID acting as the post_id.
The key piece of information you need is the field's meta key. This is typically the name you gave the field when you created it in the plugin's settings. For billing and shipping fields, the key is often prefixed with billing_ or shipping_ (e.g., billing_phone_ext).
How to Retrieve Custom Field Values
The primary method for retrieving this data is by using the WordPress function get_post_meta(). You need two things: the order ID and the correct meta key for your field.
1. Basic PHP Function
The standard way to get a value is with this function:
$custom_field_value = get_post_meta( $order_id, 'your_meta_key_here', true );
Replace your_meta_key_here with the actual name of your custom field (e.g., 'billing_dni'). The true parameter ensures it returns a single value as a string.
2. WooCommerce Order Method
If you are working within the WooCommerce order ecosystem (e.g., on the thank you page, in email templates, or with hooks that provide an $order object), you can use the WooCommerce method:
$custom_field_value = $order->get_meta( 'your_meta_key_here' );
This is often considered a more modern and reliable approach within WooCommerce contexts.
Common Use Cases and Examples
Displaying a Field in a Custom Email Template
If you are editing a WooCommerce email template, you can use the order object to output your custom field.
<?php
// Example for a field named 'addburn'
$addburn_value = $order->get_meta( 'addburn' );
if ( ! empty( $addburn_value ) ) {
echo '<p><strong>Custom Field:</strong> ' . esc_html( $addburn_value ) . '</p>';
}
?>
Creating a Shortcode to Display a Field Value
To create a shortcode that displays a custom field's value on a page, you need to securely obtain the order ID. The method for getting the order ID depends on the context (e.g., the order details page).
// Shortcode to get a custom field value (e.g., [get_custom_field field="billing_dni"])
function custom_field_shortcode( $atts ) {
$atts = shortcode_atts( array(
'field' => ''
), $atts, 'get_custom_field' );
// Try to get the order ID from the URL if on the order-received page
$order_id = absint( get_query_var('order-received') );
if ( empty( $atts['field'] ) || empty( $order_id ) ) {
return '';
}
return get_post_meta( $order_id, $atts['field'], true );
}
add_shortcode( 'get_custom_field', 'custom_field_shortcode' );
Passing Data to External Services (Google Sheets, PayPal)
When sending order data to an external service like Google Sheets via a webhook, you must explicitly map your custom fields. They are not included in the standard billing/shipping objects. You will find them in the order's metadata array.
In a Google Apps Script, you might access them like this:
// Inside a doPost(e) function
var myData = JSON.parse(e.postData.contents);
// Access a custom field from the meta_data array
var custom_field_value = '';
for (var i = 0; i < myData.meta_data.length; i++) {
if (myData.meta_data[i].key == 'your_meta_key_here') {
custom_field_value = myData.meta_data[i].value;
break;
}
}
Troubleshooting Tips
- Double-Check the Meta Key: The most common issue is using an incorrect meta key. Verify the exact name of your field in the plugin's settings.
- Enable Display in Emails: If your custom field is not showing in WooCommerce emails, ensure the "Display in Emails" option is enabled for that field within the Checkout Field Editor plugin settings.
- Underscore Prefix Note: Be aware that WooCommerce may sometimes create a duplicate meta entry with an underscore prefix (e.g.,
_billing_phone_ext). For consistency, it's often recommended to explicitly define your field names with the underscore prefix in the plugin to avoid duplication.
By understanding that custom field data is stored as order meta, you can use standard WordPress and WooCommerce functions to retrieve and display it almost anywhere you need.
Related Support Threads Support
-
How to search or filter in the admin panel for a custom field?https://wordpress.org/support/topic/how-to-search-or-filter-in-the-admin-panel-for-a-custom-field/
-
Allow custom order fields to be accessed by the WooCommerce REST APIhttps://wordpress.org/support/topic/allow-custom-order-fields-to-be-accessed-by-the-woocommerce-rest-api/
-
need a woocommerce_billing_fields style filter hookhttps://wordpress.org/support/topic/need-a-woocommerce_billing_fields-style-filter-hook/
-
Custom fields in the invoice templatehttps://wordpress.org/support/topic/custom-fields-in-the-invoice-template/
-
Custom field dont appear in invoicehttps://wordpress.org/support/topic/custom-field-dont-appear-in-invoice/
-
Hello, showing custom fields to Invoicehttps://wordpress.org/support/topic/hello-showing-custom-fields-to-invoice/
-
Integration with WooCommerce iOS apphttps://wordpress.org/support/topic/integration-with-woocommerce-ios-app/
-
Quite difficult to over-ride priorities if using custom fieldshttps://wordpress.org/support/topic/quite-difficult-to-over-ride-priorities-if-using-custom-fields/
-
order_commentshttps://wordpress.org/support/topic/order_comments/
-
Custom fields in the block checkouthttps://wordpress.org/support/topic/custom-fields-in-the-block-checkout/
-
Access of the options in PHPhttps://wordpress.org/support/topic/access-of-the-options-in-php/
-
Search for custom fieldhttps://wordpress.org/support/topic/search-for-custom-field/
-
Meta Key for Google App Scripthttps://wordpress.org/support/topic/meta-key-for-google-app-script/
-
How to fetch custom fieldshttps://wordpress.org/support/topic/how-to-fetch-custom-fields/
-
How to get the meta key of a custom field?https://wordpress.org/support/topic/how-to-get-the-meta-key-of-a-custom-field/
-
Where I will find name of $order fields?https://wordpress.org/support/topic/where-i-will-find-name-of-order-fields/
-
Can’t get custom fields values programmaticallyhttps://wordpress.org/support/topic/cant-get-custom-fields-values-programmatically/
-
Retrive field inputted info for another pluginhttps://wordpress.org/support/topic/retrive-field-inputted-info-for-another-plugin/
-
New fields API recoginzehttps://wordpress.org/support/topic/new-fields-api-recoginze/
-
Additional field value not being passed in data?https://wordpress.org/support/topic/additional-field-value-not-being-passed-in-data/
-
Insert info field before custom fieldshttps://wordpress.org/support/topic/insert-info-field-before-custom-fields/
-
calling custom fieldhttps://wordpress.org/support/topic/calling-custom-field/
-
Compatible with PDF invoices?https://wordpress.org/support/topic/compatible-with-pdf-invoices/
-
Fields to Google Sheethttps://wordpress.org/support/topic/fields-to-google-sheet/
-
Retrieving Custom Fields in Orderhttps://wordpress.org/support/topic/retrieving-custom-fields-in-order/
-
Fieldshttps://wordpress.org/support/topic/fields-15/
-
file and directoryhttps://wordpress.org/support/topic/file-and-directory/
-
Field in emails (custom template)https://wordpress.org/support/topic/field-in-emails-custom-template/
-
Pass Field Value to Paypalhttps://wordpress.org/support/topic/pass-field-value-to-paypal/
-
How can i get the value from custom field using php function?https://wordpress.org/support/topic/how-can-i-get-the-value-from-custom-field-using-php-function/
-
How to access the custom metadata during the checkout process (PHP)https://wordpress.org/support/topic/how-to-access-the-custom-metadata-during-the-checkout-process-php/
-
Add custom field in woocommerce my accounthttps://wordpress.org/support/topic/add-custom-field-in-woocommerce-my-account/
-
Move Additional Fieldshttps://wordpress.org/support/topic/move-additional-fields/
-
Accessing custom fields at the thank you pagehttps://wordpress.org/support/topic/accessing-custom-fields-at-the-thank-you-page/
-
Presale question – add to billing fieldhttps://wordpress.org/support/topic/presale-question-add-to-billing-field/
-
Custom fields also save to the userhttps://wordpress.org/support/topic/custom-fields-also-save-to-the-user/
-
WooCommerce PDF Invoices Displayhttps://wordpress.org/support/topic/woocommerce-pdf-invoices-display/
-
Compatible with woocommerce-pdf-invoices-packing-slipshttps://wordpress.org/support/topic/compatible-with-woocommerce-pdf-invoices-packing-slips-2/
-
Connection with Integromat (Google Sheets)https://wordpress.org/support/topic/connection-with-integromat-google-sheets/
-
Does the plugin add new custom fields to My Account pagehttps://wordpress.org/support/topic/does-the-plugin-add-new-custom-fields-to-my-account-page/
-
Processing of collected datahttps://wordpress.org/support/topic/processing-of-collected-data/
-
Printing a custom fieldhttps://wordpress.org/support/topic/printing-a-custom-field/
-
Get custom fields data from Make.comhttps://wordpress.org/support/topic/get-custom-fields-data-from-make-com/
-
Use the data of a custom field in post-checkouthttps://wordpress.org/support/topic/use-the-data-of-a-custom-field-in-post-checkout/
-
In which table does this plugin save the form information ?https://wordpress.org/support/topic/in-which-table-does-this-plugin-save-the-form-information/
-
Default value based on current_user datahttps://wordpress.org/support/topic/default-value-based-on-current_user-data/
-
Passing custom field to Stripe as metadatahttps://wordpress.org/support/topic/passing-custom-field-to-stripe-as-metadata/
-
Get values of new fields on email templatehttps://wordpress.org/support/topic/get-values-of-new-fields-on-email-template/
-
display additional field valueshttps://wordpress.org/support/topic/display-additional-field-values/
-
Add custom field to PDF INVOICEhttps://wordpress.org/support/topic/add-custom-field-to-pdf-invoice/
-
Accessing a field in a snippethttps://wordpress.org/support/topic/accessing-a-field-in-a-snippet/
-
How to add custom fields / meta-data in PDF invoice template?https://wordpress.org/support/topic/how-to-add-custom-fields-meta-data-in-pdf-invoice-template/
-
Insert a custom field in a woocommerce invoicehttps://wordpress.org/support/topic/insert-a-custom-field-in-a-woocommerce-invoice/
-
Prefix w/ underscore, or duplicate data in order metahttps://wordpress.org/support/topic/prefix-w-underscore-or-duplicate-data-in-order-meta/
-
Personal data retentionhttps://wordpress.org/support/topic/personal-data-retention-3/
-
Where is this data stored?https://wordpress.org/support/topic/where-is-this-data-stored/
-
Get input value from custom fieldhttps://wordpress.org/support/topic/get-input-value-from-custom-field/