0
add_action('woocommerce_before_order_notes', 'wps_add_select_checkout_field');

function wps_add_select_checkout_field( $checkout ) {

    echo '<h3>'.__('Delegates').'</h3>';

    woocommerce_form_field( 'delegate', array(
        'type'          => 'select',
        'id'            => 'delegates-choice',
        'class'         => array( 'wps-drop' ),
        'label'         => __( 'Number of delegates' ),
        'options'       => array(
            'one'       => __( '1' ),
            'two'       => __( '2' ),
            'three'     => __( '3' ),
            'four'      => __( '4' )
        )
 ),
    
    $checkout->get_value( 'delegate' ));

    
     if ('delegate' === "one") {
    woocommerce_form_field( 'inscription_textbox', array(
            'type'  => 'text',
            'class' => array( 'inscription-text form-row-wide' ),
            'label' => __( 'To whom should the inscription be made?' ),
        ), $checkout->get_value( 'inscription_textbox' ) );
     
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.