php - If else statement for EU countries in filter for WooCommerce breaks REST API

one text

Solution:

By default Woocommerce will not load user session data in rest api to improve the performance. For that you need to initialize the user session, then get the customer info.

if ( null === WC()->session ) {
   $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
    WC()->session = new $session_class();
    WC()->session->init();
}
WC()->customer = new WC_Customer( get_current_user_id(), true );
echo WC()->customer->get_billing_country();

Source