title: Set WooCommerce Price based on Custom Field and Custom Date (Not Working)
body: <p>I am working on a <strong>reversed</strong> &quot;sale price&quot; as in &quot;<code>Future Price</code>&quot; for single products in WooCommerce.</p>
  <p>The general idea is to set a price (future price) and a start + end date.
  Then, using the <code>woocommerce_product_get_price</code> filter, check if today is the same as the value of &quot;future price start date&quot; and if they are the same, change the product price.</p>
  <p>When the future price end date has passed, restore the product price into whatever the regular price is.</p>
  <p><strong>Problem is:</strong> I am not getting any errors or notices or anything like that -- which means I am lost :)</p>
  <p>To accomplish this whole thing, I have created a custom field (future price). I've also created the date fields. They are all saved and updated.</p>
  <p>If anyone can help and give me tips / pointers, I would really appreciate it. This is my second (2 out of 3) school projects due within a week.</p>
  <p><strong>This is my code in full:</strong></p>
  <pre><code>add_filter( 'woocommerce_product_get_price', 'future_product_price', 20, 2 );
  function future_product_price( $price, $product ) {
  
      if ( is_admin() ) return $price;
  
      $future_price       = get_post_meta( $product-&gt;get_id(), 'future_price', true ); // future product price
      $future_start_date  = get_post_meta( $product-&gt;get_id(), '_future_price_date_from', true ); // future product price start date
      $future_end_date    = get_post_meta( $product-&gt;get_id(), '_future_price_date_to', true ); // future product price end date
  
      if ( ! empty( $future_price ) &amp;&amp; ! empty( $future_start_date ) &amp;&amp; ! empty( $future_end_date ) ) {
  
          $future_date_time   = (int) strtotime( $future_start_date ); // convert
          $now_time           = (int) strtotime(&quot;now&quot;); // now in seconds
  
          // check if right now is the same day as the future price start date
          if ( $now_time == $future_start_date )
  
              // if they are the same, set the product price to the future price
              $price = $future_price;
      }
  
      return $price;
  }
  </code></pre>