Woocommerce付款选项仅适用于某些国家/地区

I am trying to enable and disable certain payment functions for certain countries in Woocommerce. I had placed the following code in my functions:

    function payment_gateway_disable_by_country( $available_gateways ) {
    // Abort if in admin area
    if ( is_admin() ) {
    return $available_gateways;
    }

    $billing_country  = WC()->customer->get_country();
    $shipping_country = ! empty( WC()->customer->get_shipping_country()  )       ? WC()->customer->get_shipping_country() : $billing_country;

    if ( isset( $available_gateways['invoice'] ) && $billing_country !=      'DE' ) {
    unset( $available_gateways['invoice'] );
    }

    if ( isset( $available_gateways['cod'] ) && $shipping_country !=  'DE' ) {
    unset( $available_gateways['cod'] );
    }

    return $available_gateways;
    }
    add_filter( 'woocommerce_available_payment_gateways','payment_gateway_disable_by_country');

but then I am getting a white screen with the following error message:

Fatal error: Can't use method return value in write context in /home/www/mysite/html/wordpress/wp-content/themes/mytheme/functions.php on line 10. Is there anything wrong with my code?