wordpress Custom theme should supprot woocommerce

88 views Asked by At

I have the WooCommerce REST API implemented and for themes which have WooCoomerce Support the API works fine, but for themes that dont declare WooCommerce support the REST API fails.

What does it mean when we say that the theme should declare WooCoomerce support?

What changes do i have to make? When i did my research i found the below code

add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
} 

is this all i need to add in the functions.php to declare support to WooCommerce.

1

There are 1 answers

0
Domain On BEST ANSWER

The code which you have mentioned is correct and it will also help you to declare WooCommerce support if you write the same in functions.php of the theme/child-theme of yours.

Just in case you need to verify whether the theme supports WooCommerce after making these changes you can check the using the following approach.

Theme without WooCommerce Support

enter image description here

Theme after adding WooCommerce Support

enter image description here

If this shows that your theme supports WooCommerce and still your REST API fails then it is an issue which is not related to the theme.

One of the reason can be the permalink structure of your site. - You must enable pretty permalinks, as default permalinks will not work.

For WooCommerce to fully support REST API please go through the following link for its documentation and check that all the conditions are full filled.

WooCommerce REST API

,

WooCommerce REST API

,

WooCommerce REST API Introduction

and

WooCommerce REST API v2 for adding a developer friendly approach so that the mistakes will be minimized as the library itself provides core functionality.