title: WooCommerce custom price using get_price() function
body: <p>I've currently been playing around with using multiple prices/currencies based on user location. I'm going through the whole ordering process and I'm almost there. </p>
  
  <p>I'm using the <code>get_price()</code> function to hook with <code>woocommerce_get_price</code> (located in <code>class-wc-product.php</code>, line 822) and then find custom field amounts that i have set (gb_price, us_price etc) from the product. </p>
  
  <p>All works fine in the shop, single product view, cart, checkout but when placing order it all falls back to the default base cost and currency. I've noticed that this only fails when hooking in via functions.php. If I amend the function itself directly in the class file, everything works perfectly. </p>
  
  <p>I really don't want to hack away at the core of WC so can someone have a look and tell me why it fails? Here's my code...</p>
  
  <p><strong>class-wc-product.php</strong></p>
  
  <pre><code>function get_price() {  
      return apply_filters( 'woocommerce_get_price', $this-&gt;price, $this );
  }
  </code></pre>
  
  <p><strong>functions.php</strong></p>
  
  <pre><code>add_filter('woocommerce_get_price', 'return_custom_price', $product, 2); 
  function return_custom_price($price, $product) {    
      global $post, $woocommerce;
      // Grab the product id
      $post_id = $product-&gt;id; 
      // Get user's ip location and correspond it to the custom field key
      $user_country = $_SESSION['user_location'];
      $get_user_currency = strtolower($user_country.'_price');
      // If the IP detection is enabled look for the correct price
      if($get_user_currency!=''){
          $new_price = get_post_meta($post_id, $get_user_currency, true);
          if($new_price==''){
              $new_price = $price;
          }
      }
      return $new_price;
  }   
  </code></pre>
  
  <p>So this works everywhere except the order confirmation. If I simply move the function from functions.php to the class itself within get_price(), it works perfectly.  </p>