Updated - 3 ways - (Added an alternative)
1) You can use the following code that will "avoid proceed to checkout" checkout if a postcode has not been filled:
// Avoiding checkout when postcode has not been entered
add_action( 'woocommerce_check_cart_items', 'check_shipping_postcode' ); // Cart and Checkout
function check_shipping_postcode() {
$customer = WC()->session->get('customer');
if( ! $customer['calculated_shipping'] || empty( $customer['shipping_postcode'] ) ){
// Display an error message
wc_add_notice( __("Please enter your postcode before checkout", "woocommerce"), 'error' );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
In Cart page:

In checkout page:

2) Try this alternative way (that check for postcode and redirect to cart avoiding checkout):
add_action('template_redirect', 'check_shipping_postcode');
function check_shipping_postcode() {
// Only on checkout page (and cart for the displayed message)
if ( ( is_checkout() && ! is_wc_endpoint_url() ) || is_cart() ) {
$customer = WC()->session->get('customer');
if( ! $customer['calculated_shipping'] || empty( $customer['shipping_postcode'] ) ){
wc_add_notice( __("Please enter your postcode before checkout", "woocommerce"), 'error' );
if( ! is_cart() ){
wp_redirect(wc_get_cart_url());
exit();
}
}
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
In Cart page:

3) A combination of both above (avoiding checkout page):
// Avoiding checkout when postcode has not been entered
add_action( 'woocommerce_check_cart_items', 'check_shipping_postcode' ); // Cart and Checkout
function check_shipping_postcode() {
$customer = WC()->session->get('customer');
if( ! $customer['calculated_shipping'] || empty( $customer['shipping_postcode'] ) ){
// Display an error message
wc_add_notice( __("Please enter your postcode before checkout", "woocommerce"), 'error' );
}
}
add_action('template_redirect', 'shipping_postcode_redirection');
function shipping_postcode_redirection() {
// Only on checkout page
if ( is_checkout() && ! is_wc_endpoint_url() ) {
$customer = WC()->session->get('customer');
if( ! $customer['calculated_shipping'] || empty( $customer['shipping_postcode'] ) ){
wp_redirect(wc_get_cart_url());
exit();
}
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
In Cart page:
