title: Fatal error: Uncaught Error: Call to undefined function is_product()
body: <p>After importing my production WordPress-associated website to my local Xampp environment, I get this error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Call to undefined function is_product()
    in
    C:\xampp\htdocs\public_html\siliconharvest\wp-content\themes\storefront-child\functions.php:62
    Stack trace: #0
    C:\xampp\htdocs\public_html\siliconharvest\wp-includes\class-wp-hook.php(286):
    wc_variable_simple_conditions('') #1
    C:\xampp\htdocs\public_html\siliconharvest\wp-includes\class-wp-hook.php(310):
    WP_Hook->apply_filters(NULL, Array) #2
    C:\xampp\htdocs\public_html\siliconharvest\wp-includes\plugin.php(453):
    WP_Hook->do_action(Array) #3
    C:\xampp\htdocs\public_html\siliconharvest\wp-includes\general-template.php(2614):
    do_action('wp_head') #4
    C:\xampp\htdocs\public_html\siliconharvest\wp-content\themes\storefront\header.php(18):
    wp_head() #5
    C:\xampp\htdocs\public_html\siliconharvest\wp-includes\template.php(688):
    require_once('C:\xampp\htdocs...') #6
    C:\xampp\htdocs\public_html\siliconharvest\wp-includes\template.php(647):
    load_template('C:\xampp\htdocs...', true) #7
    C:\xampp\htdocs\public_html\siliconharvest\wp-includes\general-template.php(
    in
    C:\xampp\htdocs\public_html\siliconharvest\wp-content\themes\storefront-child\functions.php
    on line 62</p>
  </blockquote>
  
  <p>I have attempted the following diagnostic steps, with no effect on the error:</p>
  
  <ol>
  <li>Disabled all plugins, including the plugin which concerns itself with products (Woocommerce)</li>
  <li>Re-named the storefront-child\functions.php file (to temporarily disable it)</li>
  <li>Changed the template to something other than store-front child</li>
  </ol>
  
  <p>Yet the error persists regardless of any of the above steps.  The correct solution must make all these errors go away.</p>
  
  <p>Edit: lines 1-73 of the functions.php file referenced in the error:</p>
  
  <pre><code>&lt;?php
  // BEGIN Remove "Storefront Designed by WooThemes" from Footer as per https://danielsantoro.com/remove-storefront-designed-woothemes/
  add_action('init', 'custom_remove_footer_credit', 10);
  function custom_remove_footer_credit()
  {
      remove_action('storefront_footer', 'storefront_credit', 20);
      add_action('storefront_footer', 'custom_storefront_credit', 20);
  }
  
  function custom_storefront_credit()
  {
  ?&gt;
      &lt;div class="site-info"&gt;
  &lt;div class="deferred-menu-items"&gt;
  &lt;ul style="list-style-type: none;" class="footer-menu"&gt;
  &lt;li style="display:inline-block" class="menu-item-156"&gt;&lt;a href="/about/"&gt;About Us&lt;/a&gt;&lt;/li&gt;&lt;!--
  --&gt;&lt;li style="display:inline-block" class="menu-item-189"&gt;&lt;a href="/faq/"&gt;FAQ&lt;/a&gt;&lt;/li&gt;&lt;!--
  --&gt;&lt;li style="display:inline-block" class="fa-delivery"&gt;&lt;a href="/delivery/"&gt;Delivery&lt;/a&gt;&lt;/li&gt;&lt;!--
  --&gt;&lt;li style="display:inline-block" class="fa-returns"&gt;&lt;a href="/returns/"&gt;Returns&lt;/a&gt;&lt;/li&gt;&lt;!--
  --&gt;&lt;li style="display:inline-block" class="menu-item-464"&gt;&lt;a href="/store-policies/"&gt;&lt;i class="far fa-handshake"&gt;&lt;/i&gt; Store Policies&lt;/a&gt;&lt;/li&gt;&lt;!--
  --&gt;&lt;!--&lt;li style="display:inline-block" class="menu-item-1024"&gt;&lt;a href="/articles/"&gt;Articles&lt;/a&gt;&lt;/li&gt;--&gt;&lt;!--
  --&gt;&lt;li style="display:inline-block" class="affiliates"&gt;&lt;a href="/about-the-silicon-harvest-affiliates-program/"&gt;&lt;i class="fas fa-bullhorn"&gt;&lt;/i&gt; Affiliates Programme&lt;/a&gt;&lt;/li&gt;
  &lt;!--&lt;li style="display:inline-block" class="fa-opas"&gt;&lt;a href="/overseas-parts-acquisition-service-opas/"&gt;Overseas Parts Acquisition Service (OPAS)&lt;/a&gt;&lt;/li&gt;--&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
          &amp;copy; &lt;?php
      echo get_bloginfo('name') . ' ' . get_the_date('Y') . ' | ABN: 31 022 705 565 | &lt;a style="color:blue" href="/terms-of-service-and-privacy-policy/"&gt;Terms of Service/Privacy Policy&lt;/a&gt; &lt;div class="front-page-contact"&gt;
  &lt;a style="color:blue" href="/contact-us/#aggs-contact-form"&gt;Contact Form&lt;/a&gt; | mob: 0424 214 930 | tel: (02) 8007 6871 &lt;!--| mob: +61 424 214 930 (international) / tel: +612 8007 6871 --&gt;| &lt;a style="color:blue" href="mailto:mail@siliconharvest.com.au"&gt;mail@siliconharvest.com.au&lt;/a&gt;&lt;br /&gt;Live contact hours from 9am-9pm (AEST/AEDT or Sydney/Melbourne/ACT/TAS time), Mon-Sun&lt;/div&gt;';
  ?&gt;
      &lt;/div&gt;&lt;!-- .site-info --&gt;
      &lt;?php
  }
  // END Remove "Storefront Designed by WooThemes" from Footer
  
  /* START add microdata relating to item condition to satisfy Google Merchant's optional advice - as per https://github.com/woocommerce/woocommerce/issues/15797#issuecomment-355744594 */
  add_filter('woocommerce_structured_data_product_offer', 'filter_woocommerce_structured_data_product', 10, 2);
  
  /**
   * Add properties to the http://schema.org/Offer markup for all products.
   */
  function filter_woocommerce_structured_data_product($markup, $product)
  {
      /* By default, we assume all products sold in the ecommerce are in new condition */
      if (empty($markup['itemCondition'])) {
          $markup['itemCondition'] = 'http://schema.org/NewCondition';
      }
      return $markup;
  }
  /* END add microdata */
  
  
  // as per https://wordpress.stackexchange.com/questions/276941/woocommerce-add-extra-field-to-variation-product/277556 
  // based on http://www.remicorson.com/woocommerce-custom-fields-for-variations/ 
  
  //THESE ACTIONS AND FILTER HANDLE YOUR PRODUCT VARIATION FIELDS + add_filter( 'woocommerce_available_variation', 'load_variation_settings_fields' ); which you have inserted into a conditional
  add_action('woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3);
  add_action('woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2);
  
  add_action('wp_head', 'wc_variable_simple_conditions');
  function wc_variable_simple_conditions()
  {
      if (is_product()) {
          global $post;
          $post_id = $post-&gt;ID;
          $product = wc_get_product($post_id);
          $type    = $product-&gt;get_type();
          if ($type == 'variable') {
              add_filter('woocommerce_available_variation', 'load_variation_settings_fields');
          } elseif ($type == 'simple') {
              add_action('woocommerce_single_product_summary', 'custom_data_above_add_to_cart_button', 41);
          }
      }
  }
  </code></pre>
  
  <p>The line <code>if (is_product()) {</code> is line 62.</p>