Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Checkout Field Manager

  • Hello,

    I use GP Premium and WooCommerce for my website and I would like to add a text field to the WooCommerce order validation form. I’ve installed the Checkout Field Manager plugin but I can’t display the field.

    I’ve tried directly in PHP in the functions.php file (thanks ChatGPT), but that doesn’t work either.
    Do you have any ideas? Are the hooks compatible with the theme?


    PHP :

    // Ajouter un champ personnalisé à la page de commande
    add_action('woocommerce_after_order_notes', 'custom_checkout_field');
    function custom_checkout_field($checkout) {
        echo '<div id="custom_checkout_field"><h2>' . __('Code d\'authentification') . '</h2>';
        woocommerce_form_field('custom_code', array(
            'type'          => 'text',
            'class'         => array('custom-code-class form-row-wide'),
            'label'         => __('Entrez votre code'),
            'placeholder'   => __('Code composé de lettres et de chiffres'),
            'required'      => true,
        ), $checkout->get_value('custom_code'));
        echo '</div>';
    // Valider le champ personnalisé
    add_action('woocommerce_checkout_process', 'custom_checkout_field_process');
    function custom_checkout_field_process() {
        if (empty($_POST['custom_code'])) {
            wc_add_notice(__('Veuillez entrer un code d\'authentification.'), 'error');
        } else {
            if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['custom_code'])) {
                wc_add_notice(__('Le code doit être composé uniquement de lettres et de chiffres.'), 'error');
    // Enregistrer la valeur du champ personnalisé dans les données de la commande
    add_action('woocommerce_checkout_update_order_meta', 'custom_checkout_field_update_order_meta');
    function custom_checkout_field_update_order_meta($order_id) {
        if (!empty($_POST['custom_code'])) {
            update_post_meta($order_id, '_custom_code', sanitize_text_field($_POST['custom_code']));
    // Afficher la valeur du champ personnalisé dans l'administration des commandes
    add_action('woocommerce_admin_order_data_after_billing_address', 'custom_checkout_field_display_admin_order_meta', 10, 1);
    function custom_checkout_field_display_admin_order_meta($order) {
        $custom_code = get_post_meta($order->get_id(), '_custom_code', true);
        if (!empty($custom_code)) {
            echo '<p><strong>' . __('Code d\'authentification') . ':</strong> ' . esc_html($custom_code) . '</p>';
  • Hi there,

    the Theme doesn’t change or interfere with Woocommerce templates, we leave them well alone 🙂

    First thing to check is whether the Checkout page is showing the legacy PHP checkout template or is it using the new Checkout Block. If its the latter then 90% of Woos hooks do not exist in the block.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.