title: WooCommerce issue: Uncaught Error: Call to a member function get_type() on bool?
body: <p>I am currently trying to implement this solution in WooCommerce provided by @LoicTheAztec.</p>
  <p><a href="https://stackoverflow.com/questions/43946264/override-external-product-url-to-add-to-cart-product-button">Override External Product URL to &quot;Add to Cart&quot; product button</a></p>
  <p>However, when I entered it into functions.php, this is the error message I get.</p>
  <p><strong>Error message that appears</strong></p>
  <pre><code>Your PHP code changes were rolled back due to an error on line 102 of file wp-content/themes/astra-child/functions.php. Please fix and try saving again.
  
  Uncaught Error: Call to a member function get_type() on bool in wp-content/themes/astra-child/functions.php:102
  Stack trace:
  #0 wp-includes/class-wp-hook.php(289): redirect_simple_product_with_external_url('https://lms.sur...')
  #1 wp-includes/plugin.php(206): WP_Hook-&gt;apply_filters('https://lms.sur...', Array)
  #2 wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php(559): apply_filters('woocommerce_add...', 'https://lms.sur...', NULL)
  #3 wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php(444): WC_Frontend_Scripts::get_script_data('wc-add-to-cart')
  #4 wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php(613): WC_Frontend_Scripts::localize_script('wc-add-to-cart')
  #5 wp-includes/class-wp-hook.php(287): WC_Frontend_Scrip
  </code></pre>
  <p><strong>This is the line 102 in question:</strong></p>
  <pre><code>if ( 'simple' == $product-&gt;get_type() &amp;&amp; ! empty( $external_url ) ){
  </code></pre>
  <p>How can I fix this?</p>
  <hr />
  <p><strong>Edit:</strong> Fixed in the linked answer <em>(updated)</em>.</p>