Unset shipping methods

Hi All

I am trying to unset shipping methods based on user role, The function is working as the echo’d headers (IE: “Trade Customer Account”, or “Customer Account”) are echoing correctly based on the user logged in, also the “unset( $methods[‘flat_rate’] );” for a customer account is working correctly.

What I am having an issue with is the trade_customer unsetting of table_rate, I simply cannot get it to work, I am using table_rate_shipping_v2 from woothemes…

Is it just the property name that I have wrong, IE: table_rate ??

function has_role($role = '',$user_id = null){
    if ( is_numeric( $user_id ) )
        $user = get_user_by( 'id',$user_id );
        $user = wp_get_current_user();

    if ( empty( $user ) )
        return false;

    return in_array( $role, (array) $user->roles );

add_filter( 'woocommerce_available_shipping_methods', 'woocommerce_unset_flatrate' );
function woocommerce_unset_flatrate( $methods ) {
    if (!is_user_logged_in()) {
		unset( $methods['flat_rate'] );
echo "<h1>Please login for shipping costs</H1>";

    if (has_role('trade_customer')){
echo "<h1>Trade Customer Account</H1>";
		unset( $methods['table_rate'] );

    if (has_role('customer')){
echo "<h1>Customer Account</H1>";

		unset( $methods['flat_rate'] );

return $methods;