You are using get_the_id()
template tag without proper loop.
Your code should be something like this
<?php
// Get any existing copy of our transient data
$suggest = get_transient('suggest');
if ( false === ( $suggest = get_transient( 'suggest' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$suggest = array();
// We will loop a custom post type and fetch custom meta from each post to be added into the autosuggest array
$query = new WP_Query( array( 'post_type' => 'my_custom_post_type', 'posts_per_page' => -1, ) );
$posts = $query->posts;
foreach($posts as $the_post) {
$value1 = get_post_meta( $the_post->ID , '_town', true );
$value2 = get_post_meta( $the_post->ID , '_quarteroftown', true );
$value3 = get_post_meta( $the_post->ID , '_street_name', true );
$value4 = get_post_meta( $the_post->ID , '_supplier_postcode', true );
if (!in_array($value1, $suggest))
{
$suggest[] = $value1;
}
if (!in_array($value2, $suggest))
{
$suggest[] = $value2;
}
if (!in_array($value3, $suggest))
{
$suggest[] = $value3;
}
if (!in_array($value4, $suggest))
{
$suggest[] = $value4;
}
}
set_transient( 'suggest', $suggest, HOUR_IN_SECONDS );
}; ?>