Custom widget placement | Judge.me

Custom widget placement

1. Move review widget to the product's tabs

Add the following code to your theme's functions.php:

if (class_exists( 'JudgeMe' )) {
    add_action( 'init', 'jgm_remove_review_widget' );

    function jgm_remove_review_widget () {
        // Remove the default widget placement
        remove_action( 'woocommerce_after_single_product_summary', array( 'JGM_Widget', 'judgeme_review_widget' ), 14 );
    }

     add_filter( 'woocommerce_product_tabs', 'jgm_add_review__widget_to_tab' );

     function jgm_add_review__widget_to_tab ($tabs) {
         $tabs['judgeme_reviews'] = array(
            'title' => __( 'Reviews', 'woocommerce' ),
            'priority' => 50,
            'callback' => array( 'JGM_Widget', 'judgeme_review_widget' )
         );

         return $tabs;
     }
}

Leex theme only

If you use Leex theme and put the widget to inside the tab, you may need additional Javascript, please put this to your theme's js file to reactive the leex widget after showing the review tab (change the review button's class to match your theme code if needed)

if (typeof jdgm !== 'undefined') {
  jdgm.$('.judgeme_reviews_tab a').click(function(){
    setTimeout(function(){ jdgm.$('.jdgm-rev-widg__reviews').masonry('layout') ;}, 300);
  });
}