Question: In one shop the following function throws a fatal error. What does the error tell me exactly?

The function: 

```
$product = wc_get_product( $product_id );
$price = $product->get_price();

```

The error:

```
Fatal error: 
Uncaught Error: Call to a member function get_price() on boolean in 

```

Does this mean that I get a boolean back instead of a string or number? The error is coming from the line where I invoke get\_price()

Answer: 
> 
> Does this mean that I get a boolean back instead of a string or number?
> 
> 
> 

Exactly. I assume that your $product\_id does not exist and wc\_get\_product() returns false in that case. However, the documentation (<https://docs.woocommerce.com/wc-apidocs/function-wc_get_product.html>) says, the method would return null on non-existant products (if you are using WooCommerce).

And: A method call on a string or a number won't work as well. You are expecting an object in your code snippet.

*Update*

Take care for the other suggestions here as well.

If you are using methods with mixed return types (in this case bool/object), you should always check the response first, before using it as an object.
If `$product` is a boolean then this line

```
$product = wc_get_product( $product_id );

```

has failed !

You might start by checking what is in `$product_id`