Woocommerce featured image of page – not product

Thanks to you I tried this on my functions.php
It worked, but also had to get the ID of the page, in my case 4.

add_action( 'woocommerce_before_main_content', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
    if ( is_product_category() ){
        global $wp_query;
        $cat = $wp_query->get_queried_object();
        $thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
        $image = wp_get_attachment_url( $thumbnail_id );
        if ( $image ) {
            echo '<div class="category-image"><img src="' . $image . '" alt="' . $cat->name . '" /></div>';
        }
    }
    if ( is_shop() ){
        $target_post_id = '4';
        $image = wp_get_attachment_url(get_post_thumbnail_id($target_post_id));
        echo '<div class="category-image"><img src="' . $image. '" alt="' . $target_post_id->name . '" /></div>';   
    }
}

error code: 523