The problem is this line:
$cat_info = get_term_by('slug', $cat, 'product_cat');
You’re trying to get a category by slug, but $cat
is undefined, so $cat_info
is false
, which means that this line:
$l_name = trim($ctitle) != '' ? $ctitle : $cat_info->name;
Is throwing the first error, because you can’t access ->name
on false
.
And on this line:
$l_href = get_term_link($cat, 'product_cat');
$l_href
is becoming a WP_Error
object because — again — $cat
doesn’t exist. This means that:
$output .= '<a class="cat-img" href="'.$l_href.'">';
Is throwing the second error, because you’re can’t concatenate a WP_Error
object into a string.