If you’re building a theme which supports but doesn’t require WooCommerce, you may want to wrap WooCommerce functionality (think cart links etc) inside a conditional query. That way, if WooCommerce isn’t activated, the functionality is simply ignored instead of producing fatal errors.
https://gist.github.com/woogists/fdf6e519d9c30d98c9878fbcbd3ba92a