$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>merge tabs in woocommerce|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

merge tabs in woocommerce

matteradmin8PV0评论

i merged the description and the additional information tab. the additional information content is shown in the description tabs.

it works fine, but the content from additional information is shown above the description content. i cant figure out why...

add_filter( 'the_content', 'customizing_woocommerce_description' );
function customizing_woocommerce_description( $content ) {

    // get attributes
    global $product;
    $attributes = do_action( 'woocommerce_product_additional_information', $product );


    // Only for single product pages (woocommerce)
    if ( is_product() ) {

        // The custom content
        $custom_content = $attributes;

        // Inserting the custom content at the end
        $content .= $custom_content;
    }
    return $content;
}



// Manipulating product tabs
add_filter('woocommerce_product_tabs', 'change_product_tab', 98);
function change_product_tab($tabs){
    global $product;

    // Remove tabs
    unset($tabs['additional_information']);

    return $tabs;
}

i merged the description and the additional information tab. the additional information content is shown in the description tabs.

it works fine, but the content from additional information is shown above the description content. i cant figure out why...

add_filter( 'the_content', 'customizing_woocommerce_description' );
function customizing_woocommerce_description( $content ) {

    // get attributes
    global $product;
    $attributes = do_action( 'woocommerce_product_additional_information', $product );


    // Only for single product pages (woocommerce)
    if ( is_product() ) {

        // The custom content
        $custom_content = $attributes;

        // Inserting the custom content at the end
        $content .= $custom_content;
    }
    return $content;
}



// Manipulating product tabs
add_filter('woocommerce_product_tabs', 'change_product_tab', 98);
function change_product_tab($tabs){
    global $product;

    // Remove tabs
    unset($tabs['additional_information']);

    return $tabs;
}
Share Improve this question asked Mar 13, 2019 at 16:59 LovinQuaQuaLovinQuaQua 833 silver badges19 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

the content from additional information is shown above the description content

Because the following code calls wc_display_product_attributes() which displays the default content for the additional information tab:

do_action( 'woocommerce_product_additional_information', $product );

To fix it, you can turn on output buffering, run the do_action() and then get the output using ob_get_clean():

function customizing_woocommerce_description( $content ) {

    // get attributes
    global $product;

    // Only for single product pages (woocommerce)
    if ( is_product() ) {

        // The custom content
        ob_start();
        do_action( 'woocommerce_product_additional_information', $product );
        $custom_content = ob_get_clean();

        // Inserting the custom content at the end
        $content .= $custom_content;
    }

    return $content;
}

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far