Q:

WooCommerce get_availability() returns an array

I'm trying to display the availability of a product inside a function using woocommerce 3.0.8.
My code is:
global $product;    
echo $product->get_availability();

It prints the word Array and nothing else. shouldn't it work?
I can't figure out what's wrong

A:

WC_Product get_availability() method return an array of 2 keys/values:

The availability text based on stock status (with the key 'availability').  You can use here WC_Product get_availability_text() method (return a string)
The availability classname based on stock status (with the key 'class')  You can use here WC_Product get_availability_class( ) method (return a string)

To see this try:
global $product;    
print_r($product->get_availability());

There is a little mistake in WooCommerce documentation as this output an array an not a string.

Update:
Using directly WC_Product get_availability_text() method this way:
global $product; 
return $product->get_availability_text();

Will replace (in a more compact way):
global $product; 
$availability = $product->get_availability();
return $availability[availability];

