Get custom fields from a custom post type with a shortcode

Get the Attribute value in the shortcode and get the custom field values:

function product_func($atts) {
    $post_id = $atts['code'];
    $key = "my_custom_field_key";//for 1 field, you can do this 6 times for the 6 values
    $custom_value = get_post_meta($post_id, $key, true);
    return $custom_value;
}

add_shortcode('product', 'product_func');

if you want to debug the post meta field values use this code:

function product_func($atts) {
    $post_id = $atts['code'];
    //lets check if we are getting the att
    echo "<h1>THE ATT, SHOULD MATCH THE CODE YOU SEND</h1></br>";
    echo "<pre>";
    var_dump($post_id);
    echo "</pre>";
    //lets check if we are getting the att
    echo "</br><h1>WE MAKE SURE THE POST IS NOT NULL, MEANING IT SHOULD EXIST</h1></br>";
    $post = get_post( $post_id );
    echo "<pre>";
    var_dump($post);
    echo "</pre>";

    //lets check the meta values for the post
    echo "</br><h1>WE LIST ALL META VALUES TO CHECK THE KEY NAME OF THE CUSTOM FIELD WE WANT TO GET</h1></br>";
    $meta = get_post_meta( $post_id );
    echo "<pre>";
    var_dump($meta);
    echo "</pre>";

    $key = "my_custom_field_key";//for 1 field, you can do this 6 times for the 6 values
    $custom_value = get_post_meta($post_id, $key, true);
    return $custom_value;
}

add_shortcode('product', 'product_func');

it shows each value needed to get the `custom field, should look like this:

enter image description here

so in my case the key would be:

$key = "MY CUSTOM FIELD";