Hello i have a big problem when i try to publish a post or a product or even when i update something i’m getting this error

Warning: Cannot modify header information – headers already sent by (output started at /home/content/a2pewpnas01_data01/19/3920219/html/wp-content/themes/electro-child-theme/functions.php:1) in /home/content/a2pewpnas01_data01/19/3920219/html/wp-includes/pluggable.php on line 1195

i think that there is something wrong wiht my php file, but i don’t know where

<?php
add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart_button_func' );

function add_content_after_addtocart_button_func() {

// Echo content.

echo '<div class="second_content"> Puedes pagar con: 
<img src="https://www.gopinstore.com/wp-content/uploads/2017/04/lolass.png"> 
<a href="https://www.gopinstore.com/3845-2/" target="_blank">Más opciones</a>
</div>';

}
add_filter( 'woocommerce_product_tabs', 'ec_child_rename_specification_tab', 20 );

function ec_child_rename_specification_tab( $tabs ) {
    if ( isset( $tabs['specification'] ) ) {
        $tabs['specification']['title'] = esc_html__( 'Características', 'electro' );
    }

    return $tabs;
}
add_filter( 'electro_register_benefits', 'ec_child_modify_register_benefits' );

function ec_child_modify_register_benefits( $benefits ) {
    $benefits = array(
        esc_html__( 'Vender productos sin comisión', 'electro' ),
        esc_html__( 'Acceder a contenidos exclusivos', 'electro' ),
        esc_html__( 'Descubrir productos únicos', 'electro' ),
    );
    return $benefits;
}

function electro_vertical_menu() {
    ?>
    <div class="col-xs-12 col-lg-3">
    <?php
        $vertical_menu_title = apply_filters( 'electro_vertical_menu_title', esc_html__( 'All Departments', 'electro' ) );
        $vertical_menu_icon  = apply_filters( 'electro_vertical_menu_icon', 'fa fa-list-ul' ); ?>
        <ul class="list-group vertical-menu animate-dropdown">
            <li class="list-group-item dropdown">
                <a href="#" data-toggle="dropdown"><i class="<?php echo esc_attr( $vertical_menu_icon ); ?>"></i> <?php echo esc_html( $vertical_menu_title ); ?></a>
                <?php
                wp_nav_menu( array(
                    'theme_location'    => 'all-departments-menu',
                    'container'         => false,
                    'menu_class'        => 'dropdown-menu yamm',
                    'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
                    'walker'            => new wp_bootstrap_navwalker(),
                ) );
                ?>
            </li>
        </ul>
    </div>
    <?php
}
/**
* XL WooCommerce Sales Trigger Class Instance
*/
$wcst_plugin_instance = WCST_Core::get_instance();

// removing below price and below add to cart buttton action hook of plugin
remove_action('woocommerce_single_product_summary', array($wcst_plugin_instance, 'wcst_position_below_price'), 17.2);
remove_action('woocommerce_single_product_summary', array($wcst_plugin_instance, 'wcst_position_below_add_cart'), 39.2);
remove_action('woocommerce_single_product_summary', array($wcst_plugin_instance, 'wcst_position_below_meta'), 41.2);

// hooking below add to cart function with 'electro_single_product_action' hook
add_action('electro_single_product_action', array($wcst_plugin_instance, 'wcst_position_below_add_cart'), 32);

// hooking below price function with 'electro_single_product_action' hook
add_action('electro_single_product_action', array($wcst_plugin_instance, 'wcst_position_below_price'), 22);

// hooking below meta function with 'woocommerce_after_single_product_summary' hook
add_action('woocommerce_after_single_product_summary', array($wcst_plugin_instance, 'wcst_position_below_meta'), 11);

function woocommerceframework_header_add_to_cart_fragment( $fragments ) {
    global $woocommerce;

    ob_start();

    ?>
    <span class="cart-contents"><a href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a></span>
    <?php

    $fragments['span.cart-contents'] = ob_get_clean();

    return $fragments;

}
if ( ! function_exists( 'electro_template_single_brand' ) ) {
    /**
     * 
     */
    function electro_template_single_brand() {

        global $product;

        $product_id = electro_wc_get_product_id( $product );
        $brands_tax = electro_get_brands_taxonomy();
        $terms      = get_the_terms( $product_id, $brands_tax );
        $brand_img  = '';

        if ( $terms && ! is_wp_error( $terms ) ) {

            foreach ( $terms as $term ) {
                $thumbnail_id   = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true );

                if ( $thumbnail_id ) {
                    $image_attributes = wp_get_attachment_image_src( $thumbnail_id, 'full' );

                    if( $image_attributes ) {
                        $image_src = $image_attributes[0];
                    }

                    $image_src  = str_replace( ' ', '%20', $image_src );
                    $brand_img  .= '<a href="' . esc_url( get_term_link( $term ) ). '"><img src="' . esc_url( $image_src ) . '" alt="' . esc_attr( $term->name ) . '" /></a>';
                } else {
                    $brand_img  .= '<a href="' . esc_url( get_term_link( $term ) ). '"><span>' . esc_attr( $term->name ) . '</span>';
                }
            }
        }

        if ( ! empty( $brand_img ) ) : ?>
        <div class="brand">
            <?php echo wp_kses_post( $brand_img ); ?>
        </div>
        <?php endif;
    }
}
add_action( 'electro_before_footer', 'ec_child_recently_viewed_products_carousel', 5 );

function ec_child_recently_viewed_products_carousel() {

    $viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', $_COOKIE['woocommerce_recently_viewed'] ) : array();
    $viewed_products = array_reverse( array_filter( array_map( 'absint', $viewed_products ) ) );

    $columns = 5;

    if ( empty( $viewed_products ) ) {
        return;
    }

    ob_start();

    $number = 12;

    $query_args = array(
        'posts_per_page' => $number,
        'no_found_rows'  => 1,
        'post_status'    => 'publish',
        'post_type'      => 'product',
        'post__in'       => $viewed_products,
        'orderby'        => 'post__in',
    );

    if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
        $query_args['tax_query'] = array(
            array(
                'taxonomy' => 'product_visibility',
                'field'    => 'name',
                'terms'    => 'outofstock',
                'operator' => 'NOT IN',
            ),
        );
    }

    $products = new WP_Query( $query_args );

    ob_start();

    if ( $products->have_posts() ) {
        woocommerce_product_loop_start();

            while ( $products->have_posts() ) : $products->the_post();

                wc_get_template_part( 'content', 'product' );

            endwhile; // end of the loop.

        woocommerce_product_loop_end();
    } 

    woocommerce_reset_loop();
    wp_reset_postdata();

    $content = ob_get_clean();

    $section_args = array(
        'products_html'     => $content,
        'section_title'     => esc_html__( 'Tu Historial', 'electro' ),
    );

    $carousel_args = array(
        'items'             => $columns,
        'responsive'        => array(
            '0'     => array( 'items' => 1 ),
            '480'   => array( 'items' => 2 ),
            '768'   => array( 'items' => 2 ),
            '992'   => array( 'items' => 3 ),
            '1200'  => array( 'items' => $columns ),
        )
    );

    echo '<div class="container">';

    electro_products_carousel( $section_args, $carousel_args );

    echo '</div>';
}

function ec_track_product_view() {
    if ( ! is_singular( 'product' ) ) {
        return;
    }

    global $post;

    if ( empty( $_COOKIE['woocommerce_recently_viewed'] ) )
        $viewed_products = array();
    else
        $viewed_products = (array) explode( '|', $_COOKIE['woocommerce_recently_viewed'] );

    if ( ! in_array( $post->ID, $viewed_products ) ) {
        $viewed_products[] = $post->ID;
    }

    if ( sizeof( $viewed_products ) > 15 ) {
        array_shift( $viewed_products );
    }

    // Store for session only
    wc_setcookie( 'woocommerce_recently_viewed', implode( '|', $viewed_products ) );
}

add_action( 'template_redirect', 'ec_track_product_view', 25 );




add_filter( 'woocommerce_product_tabs', 'ec_child_rename_reviews_tab', 20 );

function ec_child_rename_reviews_tab( $tabs ) {
    if ( isset( $tabs['reviews'] ) ) {
        $tabs['reviews']['title'] = esc_html__( 'Valoraciones', 'electro' );
    }

    return $tabs;
}


add_filter( 'woocommerce_product_tabs', 'ec_child_rename_accessories_tab', 20 );

function ec_child_rename_accessories_tab( $tabs ) {
    if ( isset( $tabs['accessories'] ) ) {
        $tabs['accessories']['title'] = esc_html__( 'Accesorios', 'electro' );
    }

    return $tabs;
}

Read more here: Error in php functions woocommerce headers


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: