Call global variable array() in woocommerce child/template

It is all fine. You just need to declare variable global first then you can set the value of this and access globally.

function my_free_shipping( $is_available ) {
global $woocommerce, $product_notfree_ship;

// set the product ids that are $product_notfree_ship
$product_notfree_ship = array( '1', '2', '3', '4', '5' );

Then again declare it globally when using again in another file

global $product_notfree_ship;

if ( is_single($product_notfree_ship) ) {
 echo 'Additional Shipping Charges Apply';
} else {
    echo 'FREE SHIPPING on This Product';
}

This is how global variable works.