Trying to list custom categories in custom post type [closed]

Try this, you can’t just throw a conditional block inside an echo statement. If you really need to it has to be a shorthand if-else, but for visual purposes I have put the statement outside the loop:

$taxonomy = 'product-categories';
$tax_terms = get_terms( $taxonomy );

foreach($tax_terms as $tax_term) {
    $terms = apply_filters( 'product-categories-images-get-terms', '' ); ?>
    $imgUrl = ( function_exists( 'z_taxonomy_image_url' ) ) ? z_taxonomy_image_url() : '';
    echo '<li><img src="' . $imgUrl . '" /><a href="' . esc_attr( get_term_link( $tax_term, $taxonomy ) ) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name . '</a></li>';
}

Short-hand PHP Examples.