How to change related product thumbnail size for display in single product page woocommerce wordpress -Solved

How to change related product thumbnail size for display in single product page woocommerce wordpress Solved

below code is tested and works fine.

add_action( 'after_setup_theme', 'rj_remove_loop_thumbnail_filter', 10 );
function rj_remove_loop_thumbnail_filter()
{
    remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
}
add_filter('woocommerce_related_products_args','rj_related_product_args');
function rj_related_product_args($query_args)
{
    if( is_singular( 'product' ) ) {
   if( ! empty( $query_args ) ) {
            set_query_var( 'related_products', true );
        }
    }
    return $query_args;
}
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_before_shop_loop_item_title','rj_change_related_product_thumb',10);
function rj_change_related_product_thumb() {
    global $wpdb,$wp_query, $post;;
        $related = get_query_var('related_products');
      if( TRUE == $related ) {
         
                if ( has_post_thumbnail() ) {
                echo get_the_post_thumbnail( $post->ID, array( 200,200)  );
            } elseif ( wc_placeholder_img_src() ) {
                echo wc_placeholder_img( $size );
            }
        } else {
            echo woocommerce_get_product_thumbnail(); 
        }
    }

Comments

Popular posts from this blog

How to add image option in nav menu in wordpress

How to add a custom email functionality in woocommerce,wordpress for example new email template for shipping order

How to change user id on checkout page for assign order to different user in woocommerce wordpress