SOLVED with the below change/addition:
$shipping = $order->get_shipping_postcode();
if ( empty($shipping) ) {
$customer_postcode = $order->get_billing_postcode();
}else {
$customer_postcode = $order->get_shipping_postcode();
}