Support » Plugin: WooCommerce » variable product and additional info tab

  • Resolved timholz


    Hi-looking at the additional info tab of variable products confuses me, for only the data (weight and dimensions) of one variation is shown. I suppose the data for the default variation is collected. Is this intentional?
    I worked out a solution, but still the question remains.
    Here is my workaround (in functions.php or plugin):

           // code reworked from woocommerce/classes/class-wc-cart.php
            // attribute slug to title
            if ( ! function_exists( 'attribute_slug_to_title' ) ) {
                function attribute_slug_to_title( $attribute ,$slug ) {
                    global $woocommerce;
                    if ( taxonomy_exists( esc_attr( str_replace( 'attribute_', '', $attribute ) ) ) ) {
                        $term = get_term_by( 'slug', $slug, esc_attr( str_replace( 'attribute_', '', $attribute ) ) );
                        if ( ! is_wp_error( $term ) && $term->name )
                            $value = $term->name;
                    } else {
                        $value = apply_filters( 'woocommerce_variation_option_name', $value );
                    return $value;
    add_filter( 'woocommerce_product_additional_information', 'tim_additional_tab', 9 );
    function tim_additional_tab( $product ){
        if (is_single(1155)){
        remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
        $variations = $product->get_available_variations();
        //print the whole array in additional tab and examine it
        //echo '<pre>';
        //echo '</pre>';
        //html and style to your needs and likings
        echo '<table class="woocommerce-product-attributes shop_attributes" style="margin-bottom:0">';
        echo '<tbody>';
        foreach ( $variations as $key ){
                $x = array_keys($key['attributes']);
                $attr = $x[0];
                $slug =$key['attributes'][$attr];
                $attrTitle = attribute_slug_to_title($attr, $slug); 
                echo '<tr class="woocommerce-product-attributes-item">';
                echo '<th class="woocommerce-product-attributes-item__label">'.$attrTitle.'</th>';
                echo '<td class="woocommerce-product-attributes-item__value">'.$key['weight_html'].' / '.$key['dimensions_html'].' / dès '.$key['display_price'].' CHF</td>';
                echo '</tr>';
            }//end foreach
        echo '</tbody>';
        echo '</table>';
        }//end single
    /// end change additional information
    • This topic was modified 1 year, 1 month ago by timholz.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support RK a11n


    Hi there,

    Admittedly I’m not quite sure of the question here – are you looking to hide that tab or are you wondering why some info is supposedly missing?

    If it’s latter, please note that you’ll need to select the “Visible on the product page” checkbox in order for it to show in that tab:

    Link to image:

    Thread Starter timholz


    Hi – Thanks for the response. I have this checkbox active.
    As for your question: No, i don’t want to hide the tab. But since it says additional information, one would expect to see data for all variations, but that is not the case. Should weights and dimensions of all the variations appear?
    regards – theo

    • This reply was modified 1 year, 1 month ago by timholz.
    Thread Starter timholz



Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘variable product and additional info tab’ is closed to new replies.