The free edition (GMCFF_* classes) applies no filters of its own. The filters below are the full edition's (namespace GatemiCheckoutFields). The storage is shared.
Filters — Full edition
gmcf_fields
The stored field configuration after it is read and normalised, before it is applied to the checkout. The screen's Choices box sets a field's choices; this filter can also supply or change them in code.
add_filter( 'gmcf_fields', function ( $fields ) {
if ( isset( $fields['order']['gmcf_delivery_slot'] ) ) {
$fields['order']['gmcf_delivery_slot']['type'] = 'select';
$fields['order']['gmcf_delivery_slot']['options'] = array(
'am' => 'Morning',
'pm' => 'Afternoon',
);
}
return $fields;
} );
The value saved on the order is the option key (am); the order screen and emails show its label.
gmcf_field_types
The field-type vocabulary. Each entry is keyed by type id, with label, wc_type (the type WooCommerce's woocommerce_form_field() draws) and has_options. A type you add is sanitised as plain text.
add_filter( 'gmcf_field_types', function ( $types ) {
$types['password'] = array(
'label' => 'Hidden text',
'wc_type' => 'password',
'has_options' => false,
);
return $types;
} );
gmcf_settings
The settings array (block_checkout, capability) after defaults. The capability key — default manage_woocommerce — decides who can open and save the screen; it has no field on the screen and is meant to be set here.
add_filter( 'gmcf_settings', function ( $settings ) {
$settings['capability'] = 'manage_options';
return $settings;
} );
Licensing and boot
gmcf_license_api_url, gmcf_update_cache_ttl, gmcf_update_retry_ttl, gmcf_sync_cache_ttl and gmcf_modules.
Actions — Full edition
gmcf_booted— after every module has booted; receives the container.
WooCommerce hooks used
| Hook | Edition | Does |
|---|---|---|
woocommerce_checkout_fields |
both | Applies the patch |
woocommerce_after_checkout_validation |
both | Required check for your own fields |
woocommerce_checkout_create_order |
both | Saves your fields' values |
woocommerce_admin_order_data_after_billing_address |
both | Shows them on the order screen |
woocommerce_email_order_meta_fields |
Full | Adds fields with Emails ticked |
woocommerce_blocks_loaded |
Full | Registers block fields |
woocommerce_get_country_locale |
both | Lays your core-field edits over every country (checkout, cart, Store API) |
woocommerce_get_country_locale_default |
both | The same over the generic definition |
woocommerce_store_api_checkout_update_order_from_request |
both | Empties a hidden field on a block order |
The gmcf_fields option
array(
'billing' => array( /* key => field */ ),
'shipping' => array(),
'order' => array(
'gmcf_delivery_instructions' => array(
'key' => 'gmcf_delivery_instructions',
'label' => 'Delivery instructions',
'placeholder' => '',
'type' => 'text',
'options' => array(),
'priority' => 30,
'required' => false,
'enabled' => true,
'custom' => true,
'class' => '',
'show_order' => false,
'show_email' => true,
),
),
)
The option is normalised whenever it is read as well as when it is saved. Sections are sorted by priority.
Field keys
A key you type is passed through sanitize_key() and prefixed with gmcf_ unless it already starts with gmcf_ or the section name followed by an underscore. WooCommerce posts each field under its key, so a custom billing field is $_POST['gmcf_…'].
Order meta
Each custom field's value is saved as _<key> — _gmcf_delivery_instructions — through the order object (HPOS and legacy alike). Empty optional fields save nothing. Neither edition deletes this meta.
$order = wc_get_order( $order_id );
$notes = $order->get_meta( '_gmcf_delivery_instructions' );
Full edition, block checkout: a field registered with the block has the id gatemi/<key> and WooCommerce stores its value under its own additional-field meta keys, not _<key>. Read it with WooCommerce's CheckoutFields service.
Options
| Option | Edition | Holds |
|---|---|---|
gmcf_fields |
both | The field edits |
gmcf_settings |
Full | block_checkout, capability |
gmcf_license |
Full | Licence |
Cron — Full edition
gmcf_license_check — twice daily, only once a licence key is entered.
CSS
No storefront CSS or JavaScript is loaded. Custom fields are drawn by WooCommerce's own woocommerce_form_field(), so they carry WooCommerce's markup: <p class="form-row" id="<key>_field">. The block on the order screen is <div class="gmcff-order-fields"> (free) or <div class="gmcf-order-fields"> (full).
#gmcf_delivery_instructions_field textarea { min-height: 6em; }
