• Hi,

    I’m trying to customize Checkout fields with WooCommerce guide. I am adding a new custom field in the bottom and making Phone-field optional/not required. I’m adding these 2 hooks to functions.php and uploading via FTP:

    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
         $fields['billing']['notes'] = array(
            'label'     => __('Order notes', 'woocommerce'),
        'placeholder'   => _x('Additional information on address, delivery etc', 'placeholder', 'woocommerce'),
        'required'  => false,
        'class'     => array('form-row-wide'),
        'clear'     => true
         );
    
         return $fields;
    }
    
    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
         $fields['billing']['billing_phone']['required'] = false;
    
         return $fields;
    }

    The problem: Separately they work perfectly, but when both added to functions.php the error occurs:

    “Fatal error: Cannot redeclare custom_override_checkout_fields() (previously declared in /www/wp-content/themes/Avada/functions.php:1447) in /www/wp-content/themes/Avada/functions.php on line 1467″

    Avada support could not figure this out. May be someone here is familiar with this error. Any help much appreciated!

  • The topic ‘Can use only one custom hook in functions.php’ is closed to new replies.