Change how product notes look in the tabs

Top WooCommerce & WordPress Plugins Forums Product Notes for WooCommerce Change how product notes look in the tabs

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #87275
    Patricia
    Guest

    Hi Support:

    I need to know if is there a way to change how it is look in the tabs because I am going to use large note.
    what I mean is there is a way I can make two columns on the front page. Some of the notes have 125 lines. So if I can make two columns I will have 1 column on the left with for example 62 and the other columns on the right with 63.

    #87276
    Tom Anbinder
    Moderator
    Plugin Support

    Hi Patricia,

    Sounds like a useful feature – let me try to add it to the plugin. Will get back to you about this soon.

    #87277
    Tom Anbinder
    Moderator
    Plugin Support

    Hi Patricia,

    As promised, we’ve just released a new plugin version (v2.2.0), where I’ve added some new options and filters, which should solve our task.

    First of all – if you are going to use multiple notes per product, and you want to display each note in a separate column, here is what you need to do:

    1. Set the “Frontend Options > Product tab > Tab content” option to:

    <table><tbody><tr><td>%product_notes%</td></tr></tbody></table>

    2. Set the “Frontend Options > Product tab > Notes glue” option to:

    </td><td>

    Now, if you meant that you want to split a single note into columns, you’ll also need to add a small PHP snippet to your site. If that’s good enough, here is what you need to do:

    1. Set the “Frontend Options > Product tab > Tab content” option to its default value, i.e.:

    %product_notes%

    2. Set the “Frontend Options > Product tab > Notes glue” option to its default value (this is actually not really important, as it’s only used if you have multiple notes per product), i.e.:

    <br>

    3. Disable the “Frontend Options > Product tab > Replace line breaks” checkbox. This is needed to properly count the total number of lines in the note in our snippet.

    4. And finally you’ll need to add this PHP snippet to your (child) theme’s functions.php file. This snippet will count the total number of lines in the note, then it will find the “center” (i.e. half of the total lines number), and then it will split that note into equal columns:

    if ( ! function_exists( 'my_alg_wc_pn_product_tab' ) ) {
        function my_alg_wc_pn_product_tab( $result, $private_or_public, $product_id ) {
            $_result     = array();
            $data        = explode( PHP_EOL, $result );
            $total_lines = count( $data );
            $half_lines  = ( int ) round( $total_lines / 2 );
            foreach ( $data as $i => $row ) {
                $_result[] = $row . '<br>';
                if ( ( $i + 1 ) === $half_lines ) {
                    $_result[] = '</td><td>';
                }
            }
            return '<table><tbody><tr><td>' . implode( '', $_result ) . '</td></tr></tbody></table>';
        }
        add_filter( 'alg_wc_pn_product_tab', 'my_alg_wc_pn_product_tab', 10, 3 );
    }
    

    Hope that helps. Please let me know if this is what we needed, or if you have any questions.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.