Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1224013
    Oscar
    Participant

    Hello again!

    I have two questions in this post.

    How can i change the name of input fields?
    How can i include a custom field to date of birth?

    http://www.intercambioesportivo.com/

    http://www.intercambioesportivo.com/finalizar-inscricao/

    I need to change the field name “name” to something else. Only the label.

    Thank you!

    #1224234
    Rupok
    Member

    Hi there,

    I can’t see any form on your page. Would you point us with a screenshot?

    Thanks!

    #1224254
    Oscar
    Participant
    This reply has been marked as private.
    #1224751
    Lely
    Moderator

    Hi Oscar,

    Please try adding the following code on Appearance > Customize > Custom > Edit Global javascript:
    jQuery('#billing_first_name_field [for="billing_first_name"]').text("NewTextforName");

    I also found that this current custom code is giving you syntax error. We need to fixed this first because it will prevent above code from working:

     function navbarChangeColor() {
        var $slider         = $(\'.x-slider-revolution-container.below\'),
            $sliderHeight   = $slider.outerHeight();
            $navbar         = $(\'.x-navbar\');
    
        if( $(window).scrollTop() > $sliderHeight ) {
          $navbar.addClass(\'nb-trans\');
        } else {
          $navbar.removeClass(\'nb-trans\');
        }
      }

    Update to this:

     function navbarChangeColor() {
        var $slider         = $('.x-slider-revolution-container.below'),
            $sliderHeight   = $slider.outerHeight();
            $navbar         = $('.x-navbar');
    
        if( $(window).scrollTop() > $sliderHeight ) {
          $navbar.addClass('nb-trans');
        } else {
          $navbar.removeClass('nb-trans');
        }
      }

    Hope this helps.

    #1225128
    Oscar
    Participant

    Thanks, it worked!

    Also fix the code as indicated me.
    Nice to know I can count on your concern.

    I have this final question on another topic you and Theme.co team helped me to put custom fields in the registration stand via functions.php.

    I could do other alone, but I have no idea how to create a field “date of birth”.

    Can you help me?

    #1225201
    Rad
    Moderator

    Hi there,

    Is it ACF related and where it should be displayed? Please provide the other thread for reference.

    Thanks!

    #1227099
    Oscar
    Participant

    This is the code that one of his colleagues gave me. It includes a field in woocommerce form to finalize the purchase.

    /**
     * Custom Field Nome do Responsável
     **/
    
    add_action( 'woocommerce_before_order_notes', 'nome_responsavel' );
     
    function nome_responsavel( $checkout ) {
     
        echo '<div id="nome_responsavel">';
     
        woocommerce_form_field( 'nome_responsavel', array(
            'type'          => 'text',
            'class'         => array('nome_responsavel form-row-wide'),
            'label'         => __('Nome do Responsável'),
            'placeholder'   => __('Digite o nome do Responsável pagante'),
            ), $checkout->get_value( 'nome_responsavel' ));
     
        echo '</div>';
     
    }
    add_action('woocommerce_checkout_process', 'validar_nome_responsavel_woocommerce');
     
    function validar_nome_responsavel_woocommerce() {
     
        if ( empty( $_POST['nome_responsavel']) )
            wc_add_notice( __( 'Obrigatório o preenchimento.' ), 'error' );
    }
    
    add_action( 'woocommerce_checkout_update_order_meta', 'novo_campo_checkout_order' );
     
    function novo_campo_checkout_order( $order_id ) {
        if ( ! empty( $_POST['nome_responsavel'] ) ) {
            update_post_meta( $order_id, 'Nome do Responsável', sanitize_text_field( $_POST['nome_responsavel'] ) );
        }
    }
    
    add_action( 'woocommerce_admin_order_data_after_billing_address', 'mostrar_nome_responsavel', 10, 1 );
     
    function mostrar_nome_responsavel($order){
        echo '<p><strong>'.__('Nome do Responsável').':</strong> ' . get_post_meta( $order->id, 'Nome do Responsável', true ) . '</p>';
    }
    
    /**

    Can you help me change to a field to include the date of birth?

    #1227133
    Rad
    Moderator

    Hi there,

    The same as where this is placed

       echo '<div id="nome_responsavel">';
     
        woocommerce_form_field( 'nome_responsavel', array(
            'type'          => 'text',
            'class'         => array('nome_responsavel form-row-wide'),
            'label'         => __('Nome do Responsável'),
            'placeholder'   => __('Digite o nome do Responsável pagante'),
            ), $checkout->get_value( 'nome_responsavel' ));
     
        echo '</div>';

    Example,

        echo '<div id="nome_responsavel">';
     
        woocommerce_form_field( 'nome_responsavel', array(
            'type'          => 'text',
            'class'         => array('nome_responsavel form-row-wide'),
            'label'         => __('Nome do Responsável'),
            'placeholder'   => __('Digite o nome do Responsável pagante'),
            ), $checkout->get_value( 'nome_responsavel' ));
     
        echo '</div>';
    
        echo '<div id="woo_birth_date">';
     
        woocommerce_form_field( 'woo_birth_date', array(
            'type'          => 'text',
            'class'         => array('woo_birth_date form-row-wide'),
            'label'         => __('Birth Date'),
            'placeholder'   => '',
            ), $checkout->get_value( 'woo_birth_date' ));
     
        echo '</div>';

    Then if you have a jQuery Datepicker library, you can simply attached it to .woo_birth_date class.

    Example, let’s say you already installed your Datepicker library then you can add this to your custom javascript.

    (function($) {
      $('.woo_birth_date').datepicker();
    }(jQuery));

    Another sample http://stackoverflow.com/questions/27462984/use-jquery-datepicker-in-wordpress

    Datepicker is optional, the field should work as normal textbox without it.

    Hope this helps.

  • <script> jQuery(function($){ $("#no-reply-1224013 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>