WooCommerce 9.0.0 Update – Class ‘WC_Legacy_API’ not found

Table of Contents

Background - WooCommerce Legacy API Removal v9.0.0

Update 21/06 – WooCommerce V9.0.1 has been released which should mitigate this issue.

This post was updated 20/06/24 as new information regarding working around the problem became available. 

WooCommerce announced the deprecation of the “Legacy API” back in 2023. The deprecation notice included the announcement of a new separate WooCommerce Legacy REST API Plugin which would effectively allow people to still run the Legacy API if it was required. WooCommerce successfully eliminated the Legacy API from their core code, while still offering users the choice to use it, if needed. 

This removal from core happened in release 9.0.0 which is documented in the release notes as “Update – Replace the Legacy REST API with a stub that always returns an error #40627

 

WooCommerce Legacy API Plugin not working in 9.0.0

As WooCommerce 9.0.0 has been released and sites are currently being upgraded, multiple reports of the plugin not working have rolled in. This includes directly to the plugin support forum.

The error being experienced is similar to the following:

 Fatal error: Uncaught Error: Class 'WC_Legacy_API' not found in /home/wordpress/public_html/wp-content/plugins/woocommerce/includes/class-wc-api.php:19
Stack trace:
#0 /home/wordpress/public_html/wp-content/plugins/woocommerce/includes/class-wc-autoloader.php(54): include_once()
#1 /home/wordpress/public_html/wp-content/plugins/woocommerce/includes/class-wc-autoloader.php(98): WC_Autoloader->load_file('/home/wordpress/...')
#2 [internal function]: WC_Autoloader->autoload('wc_api')
#3 [internal function]: spl_autoload_call('WC_API')
#4 /home/wordpress/public_html/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php(146): class_exists('WC_API')
#5 /home/wordpress/public_html/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php(19): WC_Legacy_REST_API_Plugin::legacy_api_still_in_woocommerce()
#6 /home/wordpress/public_html/wp-includes/class-wp-hook.php(324): WC_Legacy_REST_API_Plugin::on_woocommerce_init('')
#7 /home/wordpress/public_html/wp-includes/class in /home/wordpress/public_html/wp-content/plugins/woocommerce/includes/class-wc-api.php on line 19

Workaround - Updated 20/06

The issue seems to have been caused by a file that wasn’t removed by the WordPress auto updating function. Re-installing v9.0.0 has been found as an effective fix. The following methods can be tried:

1. WP-CLI Re-install WooCommerce v9.0.00

Using WP-CLI, you can force the re-install of WooCommerce v9.0.0 using the following steps (please backup your site first):

wp plugin deactivate woocommerce
wp plugin install woocommerce --version=9.0.0 --force
wp plugin activate woocommerce
wp plugin status woocommerce

2. Re-install from zip via WP Admin

If you still have access to the WP Admin area, can take the following steps:

  1. Download the zip of v9.0.0 
  2. WP Admin > Plugins – Remove existing WooCommerce plugin
  3. WP Admin > Plugins > Add New Plugin > Upload Plugin and then use the zip you downloaded in step1
If you’re a Wordify customer, please just contact support and we will fix it for you. 

Update 21/06 – WooCommerce V9.0.1 has been released which should mitigate this issue.

Is it time for a better WordPress host?

You might also like..

Are you wasting money on your current hosting provider?

Related Posts