WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Custom Override - Cannot modify header information (9 posts)

  1. nickzee
    Member
    Posted 1 year ago #

    Followed these instructions (http://wcdocs.woothemes.com/snippets/tutorial-customising-checkout-fields-using-actions-and-filters/#section-4) for adding a new field to the checkout form, and changing the text in the Order Notes box.

    Everything worked great (thanks for the tut, btw!), but I'm getting the below error, when changing any setting in the general settings tab of woocommerce plugin. The error loads in the admin section of WP, not the website.

    "Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 876"

    I'm using Responsive Child theme and added everything to the function.php in this fashion.

    (this is the start of line 16)

    <?php
    // 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['order']['order_comments']['placeholder'] = 'Send a note to the Bride and Groom!';
         ;
    	 return $fields;
    	 }
    
    ?>
    
    <?php
    /**
     * Add the field to the checkout
     **/
    add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
    
    function my_custom_checkout_field( $checkout ) {
    
        echo '<div id="my_custom_checkout_field"><h3>'.__(' Couple').'</h3>';
    
        woocommerce_form_field( 'my_field_name', array(
            'type'          => 'text',
            'class'         => array('my-field-class form-row-wide'),
            'label'         => __(''),
            'placeholder'       => __('Groom Last Name Bride Last Name'),
            ), $checkout->get_value( 'my_field_name' ));
    
        echo '</div>';
    }
    ?>
    <?php
    /**
     * Process the checkout
     **/
    add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
    
    function my_custom_checkout_field_process() {
        global $woocommerce;
    
        // Check if set, if its not set add an error.
        if (!$_POST['my_field_name'])
             $woocommerce->add_error( __('Please enter the last names into the Bride and Groom field Below.') );
    }
    ?>
    
    <?php
    /**
     * Update the order meta with field value
     **/
    add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');
    
    function my_custom_checkout_field_update_order_meta( $order_id ) {
        if ($_POST['my_field_name']) update_post_meta( $order_id, 'My Field', esc_attr($_POST['my_field_name']));
    }
    ?>

    This is line 876 of pluggable.php

    header("Location: $location", true, $status);

    Any advice for this situation?

    Thank you!

    http://wordpress.org/extend/plugins/woocommerce/

  2. nickzee
    Member
    Posted 1 year ago #

    This issue is worse then I though.

    Received these error at the wp-login.php screen.

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-login.php on line 368
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-login.php on line 380
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 697
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 698
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 699
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 700
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 701
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 702
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 705
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 706
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 707
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 708
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 711
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 712
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 713
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 714

    At these after logging in

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-login.php on line 368
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-login.php on line 380
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 680
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 681
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 682
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/53/10228053/html/wp-content/themes/responsive-child-theme/functions.php:16) in /home/content/53/10228053/html/wp-includes/pluggable.php on line 876
  3. nickzee
    Member
    Posted 1 year ago #

    Solved, by removing spaces in functions.php

    ?>
    
    <?php

    to

    ?>
    <?php
  4. Daniel Waltz
    Member
    Posted 1 year ago #

    Thank you for posting this solution! I was having the same issue and this worked for me.

  5. Julius123
    Member
    Posted 1 year ago #

    Thank you again. I had the same problem, also worked for me.

  6. VladislavV
    Member
    Posted 11 months ago #

    Thank you so much.

    I had the same problem after I registered the sidebars in my child theme. I wasn't able to update the theme options.

    I didn't delete those spaces though. I just took all my functions inside the tags <?php ?>. Without closing and opening them again.

  7. chlustanec
    Member
    Posted 10 months ago #

    you solved my problem and now I don't have to commit a suicide :D THANKS

  8. jordonmallen
    Member
    Posted 9 months ago #

    Had the same error. Simply removed the blank lines at the end of my functions.php file after the closing PHP tag inside of the theme directory. Was getting the error after I put a second install of WordPress inside my existing WordPress site.

    Note: the error may occur again if you have a WordPress install inside of another wordpress site. Make sure you edit both the new themes functions.php file as well as the original themes functions.php file to avoid any more future complications/errors.

    The error can also be caused by tags being in front of your opening PHP tag, inside of your functions.php file. Remove the tags or reorder them if possible. Remove everything before your opening PHP tag. Lines, spaces, characters, other tags.

    Some plugins will also cause this error. This error can prevent you from logging into your wordpress site. I had to use FTP to download my functions.php. I would reccomend FileZilla. Cheers and happy coding!

  9. piccart
    Member
    Posted 7 months ago #

    got this problem as well after updating a function file in the functions subfolder of the Canvas template.

    sorted deleting the blank space between php closing and new php opening tags..

    the weird thing is that the file was on the server and it was running fine even with that blank line space, then I have downloaded it with ftp, updated in another line and uploaded. and suddenly wordpress realized about that blank space and crashed..

    does anyone have an explanation for this? why before it was fine and then when I have updated the file suddenly that blank line caused the crash?

    -Andrea

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic