Forums

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

  1. nickzee
    Member
    Posted 4 months 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 4 months 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 4 months ago #

    Solved, by removing spaces in functions.php

    ?>
    
    <?php

    to

    ?>
    <?php
  4. Daniel Waltz
    Member
    Posted 3 months ago #

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

  5. Julius123
    Member
    Posted 2 months ago #

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

Reply

You must log in to post.

About this Plugin

About this Topic