Posted by

Woocommerce product is not purchasable

This issue often to happen when you add a product programmatically. Probably the third party api source where the product are coming, have an empty price.

To fix it, you just have to edit each product and set a default price, however given that it is coming from an API or other source, you might already have created hundred or thousand products.

So the easy solution was to set a default price through code, so it'll be applied to all products.

function wc_default_price($price) {
	if(empty($price) || $price == null || $price == "") {
		$price = 0;
	}
	return $price;
}

add_filter('woocommerce_get_price','wc_default_price', 10,1);

That's it! Product should now be purchasable.