After searching for a while I decided that it would be best to pay somebody to figure this out, and here I found the solution "http://www.wpquestions.com/question/show/id/8543".
Thanks to "Hariprasad" for the solution.
<?php
$args = array('type'=> 'products','parent'=> 0,'child_of'=>0,'orderby'=> 'id','order'=> 'ASC','hide_empty'=> 0,'taxonomy'=> 'product_type',);
$categories = get_categories( $args );
echo '<ul>';
foreach ( $categories as $category ) {
echo '<a href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a>';
query_posts(array( 'post_type' => 'products','parent'=> 0,'child_of'=>0,'showposts' => -1,'tax_query' => array(
array('include_children'=>false,
'taxonomy' => 'product_type',
'terms' => $category->term_id,
'field' => 'term_id',
)
),
'orderby' => 'title',
'order' => 'ASC' )
);
if(have_posts())
{
echo '<ul>';
while ( have_posts() ) : the_post();
echo '<li>';
?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><?php
echo '</li>';
endwhile;
echo '</ul>';
}
wp_reset_query();
$subargs = array('type'=> 'products','child_of'=> $category->term_id,'orderby'=> 'id','order'=> 'ASC','hide_empty'=> 0,'taxonomy'=> 'product_type',);
$subcategories = get_categories( $subargs );
if($subcategories)
{
echo '<ul>';
foreach ( $subcategories as $subcategory ) {
echo '<a href="' . get_category_link( $subcategory->term_id ) . '">' . $subcategory->name . '</a>';
query_posts(array( 'post_type' => 'products','showposts' => -1,'tax_query' => array(
array(
'taxonomy' => 'product_type',
'terms' => $subcategory->term_id,
'field' => 'term_id',
)
),
'orderby' => 'title',
'order' => 'ASC' )
);
while ( have_posts() ) : the_post();
echo '<li>';
?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><?php
echo '</li>';
endwhile;
wp_reset_query();
}
echo '</ul>';
}
}
echo '</ul>';
?>