• I am trying to add some extra fields to the registration form in Woocommerce by following the post on

    , but I am getting the following error:
    ” Parse error: syntax error, unexpected ‘{‘ in C:\Apache24\htdocs\wordpress\wp-content\themes\flatsome\functions.php on line 14″

    Here is the code:

    <?php
    /**
     * Flatsome functions and definitions
     *
     * @package flatsome
     */
    
    require get_template_directory() . '/inc/init.php';
    
    /**
     * Note: Do not add any custom code here. Please use a child theme so that your customizations aren't lost during updates.
     * http://codex.wordpress.org/Child_Themes
     */
    function wooc_extra_register_fields(){
    ?>
    
    <p class="form-row form-row-first">
    <label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?><span class="required">*</span></label>
    <input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
    </p>
    
    <p class="form-row form-row-last">
    <label for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?><span class="required">*</span></label>
    <input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
    </p>
    
    <div class="clear"></div>
    
    <p class="form-row form-row-wide">
    <label for="reg_billing_phone"><?php _e( 'Phone', 'woocommerce' ); ?><span class="required">*</span></label>
    <input type="text" class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php if ( ! empty( $_POST['billing_phone'] ) ) esc_attr_e( $_POST['billing_phone'] ); ?>" />
    </p>
    
    <?php
    }
    add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );

    Can Anyone Help me solving this problem ?!!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Parse error: syntax error, unexpected '{' when editing function.php’ is closed to new replies.