This is actually a PHP syntax typo not a WooCommerce function misunderstanding. The line
$_product = wc_get_product('$courseID');
asks for a product with an ID that matches a string that starts with a dollar sign (and is followed by eight other letters). Why? PHP does not evaluate variables inside single-quoted strings the way it does for double-quoted strings.
The $courseID
variable holds a number, and the string 7172
can also be "cast" to a number, so neither of them fail. The following two corrected versions of the line are equivalent (unless strict typing is turned on):
$_product = wc_get_product("$courseID");
$_product = wc_get_product( $courseID );