Add custom checkout fields to WooCommerce checkout

Custom checkout fields let you ask customers for anything your store needs at checkout, such as a gift message, a delivery note or a PO number, and save the answer on the order. You add them in the Checkout Editor, without code.

When you’d use this

  • You need information WooCommerce doesn’t ask for, like a gift message or a delivery instruction.
  • You want customers to confirm something before they pay, such as agreeing to a policy.
  • You want to sell an add-on at checkout, such as gift wrapping, with a fee when it’s chosen.

For examples you can copy, see Custom checkout field recipes.

Add a custom field

1. Open the Checkout Editor

Go to CheckoutWC » Checkout Editor and expand Slots. Slots are the places on the checkout where you can add fields, order bumps, badges and other items.

2. Choose where the field goes

Expand the slot you want, then click + (or Add item in an empty slot). Fields can go in any of these slots:

  • Before Express Checkout, After Customer Account, After Delivery Method
  • After Shipping Address, After Shipping Methods: these aren’t shown for orders that don’t need shipping, such as digital products or pickup
  • After Payment Methods, After Billing Address
  • Before Terms & Conditions, After Terms & Conditions, After Complete Order
  • Before Cart Summary Items, After Cart Summary Items, Before Cart Summary Totals, After Cart Summary Totals: on phones and tablets, where the cart summary collapses, fields in these slots move above the terms and conditions

A field can be in one slot at a time.

3. Create the field

Under Custom Fields, click + New custom field. Fill in the settings below, then click Add custom field.

4. Save

Click Save Changes at the top of the Checkout Editor. The field now shows on your checkout.

Field settings

Type

Text, Text area, Dropdown, Radio buttons or Checkbox.

Label

What customers see next to the field. The field’s internal name is made from the label when you first save it, and doesn’t change if you edit the label later.

Placeholder

Example text shown inside an empty text or text area field.

Character limit

The most characters a text or text area field accepts. Leave it blank for no limit. Customers see a running count as they type.

Margin

Space around the field, written like CSS, for example 10px 0 20px 0.

Required

Customers must fill in the field, or select the checkbox, before they can place the order.

Options

For dropdown and radio fields: the choices customers pick from. Click + Add option to add one, and use the arrows to reorder them.

Show a field only when it applies

Under Display conditions, click Add rule to show the field only in some situations, for example only when the cart contains a certain product, or only for one shipping country. With more than one rule, the field shows only when all of them match.

You can base rules on the cart (its products, categories, tags, quantities, subtotal or coupons), the customer’s order history, product stock, the shipping or billing country, and the customer’s user role.

A field that’s hidden by its rules isn’t required, doesn’t add a fee and isn’t saved on the order. So a required field with rules is only required when it shows. The checkout updates which fields show as the customer changes their cart or address.

There’s no rule for the chosen shipping method.

Charge a fee

Any field can add a fee to the order. Under Adds a fee, choose Fixed amount or Percentage:

  • For a dropdown or radio field, set an amount for each option. The fee is added when that option is chosen.
  • For a checkbox, the fee is added when it’s selected.
  • For a text or text area field, the fee is added when the customer enters anything.

For a percentage, choose what it’s a percentage of under Percentage of: order items after or before discounts, or order items and shipping after or before discounts. If your store charges tax, you can also include tax in that amount.

More fee settings:

  • Charge tax on this fee: shown when your store has taxes turned on. Choose the Tax class to use.
  • Show the fee in each option or Show the fee in the field label: adds the price after the label, such as “Gift wrap (+$5.00)” or “Tip (+10%)”. On by default.
  • Fee label: the name of the fee in the cart totals, on the order and in emails. It defaults to the field label. For dropdown and radio fields, the chosen option is added after it, such as “Gift wrap: Premium box”.

Where customers’ answers appear

  • Your order screen: in a Checkout Fields section below the addresses.
  • The customer’s order details: under Additional details on the thank you page and in My Account.
  • Order emails: with the other order details, in the emails WooCommerce sends you and the customer.

For a dropdown or radio field, the order shows the chosen option. For a checkbox, it shows “Yes”.

Other ways to add fields

If you already use a checkout field editor plugin, CheckoutWC works with WooCommerce Checkout Field Editor and ThemeHigh Checkout Field Editor, and the fields they add show on the CheckoutWC checkout. CheckoutWC keeps control of the billing and shipping address fields, so with WooCommerce Checkout Field Editor you work in its Additional Fields tab.

To let either plugin change the address fields too, turn on its override under CheckoutWC » Integrations: Enable Checkout Field Editor address field overrides. (Not Recommended) or Enable ThemeHigh Checkout Field Editor address field overrides. The WooCommerce Checkout Field Editor override doesn’t work with separate house number and street name fields, the full name field or Fetchify.

Layout classes and select fields in ThemeHigh

ThemeHigh Checkout Field Editor lets you set a CSS class on each field. Set the fields in the order you want, then add one of these classes to each to set its width:

Class Width
form-row-wide Full width
form-row-first and form-row-last Half width (6 of 12 columns)
col-lg-3 3 of 12 columns (25%)
col-lg-4 4 of 12 columns (33%)
col-lg-6 6 of 12 columns (50%)
col-lg-8 8 of 12 columns (66%)
col-lg-9 9 of 12 columns (75%)

A field with none of these classes is full width.

CheckoutWC styles select fields itself. If a ThemeHigh select field shows as a searchable select2 dropdown and you’d rather keep CheckoutWC’s own select, add the class cfw-no-select2 to that field.

Keep billing and shipping fields in sync

When you add a field to the billing address with an editor plugin’s address override, add the matching field to the shipping address too. That way the value is saved when the customer picks “Same as shipping address”. Two rules make it work:

  • Start the field names with shipping_ and billing_, for example shipping_fax and billing_fax.
  • Give the two fields the same name after the prefix. CheckoutWC copies each shipping_ value to the billing_ field with the same name.

Add a field with code

Developers can add a field with WooCommerce’s woocommerce_form_field() on one of CheckoutWC’s checkout actions, then save the answer on the order. This example adds a greeting card text area before the terms and conditions, saves it, and shows it on the order screen. Add it in the PHP Snippets box (CheckoutWC » Advanced, Scripts tab), a child theme’s functions.php or a code snippets plugin:

// Show the field on the checkout.
add_action( 'cfw_checkout_before_payment_method_terms_checkbox', function () {
    woocommerce_form_field(
        'greeting_card',
        array(
            'type'        => 'textarea',
            'label'       => 'Greeting card message',
            'placeholder' => 'Add a message for the card',
            'required'    => false,
        ),
        WC()->checkout()->get_value( 'greeting_card' )
    );
} );

// Save the answer on the order.
add_action( 'woocommerce_checkout_create_order', function ( $order ) {
    if ( ! empty( $_POST['greeting_card'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
        $order->update_meta_data( 'greeting_card', sanitize_textarea_field( wp_unslash( $_POST['greeting_card'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
    }
} );

// Show it on the order edit screen.
add_action( 'woocommerce_admin_order_data_after_billing_address', function ( $order ) {
    $message = $order->get_meta( 'greeting_card' );

    if ( $message ) {
        echo '<p><strong>Greeting card:</strong><br>' . esc_html( $message ) . '</p>';
    }
} );

Change cfw_checkout_before_payment_method_terms_checkbox to another action to move the field; the Actions reference lists them all, and the Visual hook guide shows where each one sits. WooCommerce checks the checkout’s security nonce before woocommerce_checkout_create_order runs, which is why the example reads $_POST there. A store that uses the WooCommerce checkout without CheckoutWC can add the same field with the woocommerce_checkout_fields filter instead, using $fields['order']['greeting_card'] = array( 'type' => 'textarea', 'label' => 'Greeting card message' );.

Common issues

A field isn’t showing on the checkout

  • Check that you clicked Save Changes in the Checkout Editor.
  • Check the field’s display conditions.
  • Fields in After Shipping Address or After Shipping Methods don’t show for orders that don’t need shipping.
  • If your license lapses, fields other than text fields are kept but hidden from the checkout, and the editor shows them as locked and read-only. Renew your license to show them again (see Manage your CheckoutWC license), or delete them.

A required field was empty on an order paid with express checkout

Express payment buttons, such as Apple Pay, can let a customer pay before filling in a required field. The order screen then shows “Not collected – placed with express checkout”. To prevent this, open the Express Checkout section of the Checkout Editor and turn off Ignore Required Custom Fields. Express payment buttons are then hidden while a required custom field is showing.

“[Field] is a required field.”

The customer left a required field empty, or didn’t select a required checkbox.

“[Field] must be [number] characters or fewer.”

The answer is longer than the field’s Character limit.

The field label isn’t translated

Labels, options and fee labels you type in the editor show as you typed them, in every language. Translation plugins don’t pick them up.

Keep learning