caskew2154
2/21/2020 - 9:42 AM

Move Variation Description to Main

Copies the Variation Description into the Main Description.

add_action( 'wp_footer', 'move_variation_description' );
function move_variation_description() {
    global $product;
    // Only on single product pages for variable products
    if ( ! ( is_product() && $product->is_type('variable') ) ) return;
    // jQuery code
    ?>
    <script>
        var $ = jQuery;
        function transferDesc() {
            var newDesc = $('.woocommerce-variation-description p').html();
            $('#tab-description .product-post-content').html(newDesc);
        }

        $('table.variations select').change(function() {
            setTimeout(function() {transferDesc()}, 300);   
        });
        //Initialise
        $( document ).ready(function() {
            setTimeout(function() {transferDesc()}, 300); 
        }) 
    </script>
<?php }