title: Using wc_get_product() with a PHP variable for product ID
body: <p>I'm building out custom landing pages for products in WooCommerce and I'd like to get the product price amongst other things in order to display them on the landing page.  </p>
  
  <p>Each landing page has some custom fields which allow the WP Admin to add in content, for the landing page as well as the product ID, which will then be used to generate the product price, checkout URL etc.. </p>
  
  <p>I can't get the <code>wc_get_product();</code> to work with my custom field or a variable built off that. It only works when I use a straight ID.  I think there's something I'm not understanding about how variables work within PHP. Here's my code. </p>
  
  <pre><code>&lt;?php 
  
  //Gets the course ID from the custom field entered by user
  $courseID = the_field('course_id');
  
  // This line is where the problem is...
  $_product = wc_get_product('$courseID');
  
  // If I replace the line above with this line
  // $_product = wc_get_product('7217');
  //  everything works great, but that does not let 
  // each landing page function based on the custom fields where the user determines 
  // the product ID they are selling on that landing page.
  
  
  // Get's the price of the product
  $course_price = $_product-&gt;get_regular_price();
  
  // Output the Course price
  ?&gt;  &lt;span class="coursePrice"&gt;$&lt;?php echo $course_price;?&gt;&lt;/span&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Update</strong> </p>
  
  <p>I get the following error using <strong><code>wc_get_product( $courseID );</code></strong> or <strong><code>get_product( $courseID );</code></strong>:</p>
  
  <pre class="lang-html prettyprint-override"><code>Fatal error: Call to a member function get_regular_price() on a non-object in ... 
  </code></pre>