Developer Advisory: Legacy REST API error in WooCommerce 9.0

⚠️ We have released WooCommerce 9.0.1 to address this issue. Please upgrade if you are experiencing this error.

The Details

An issue in WooCommerce 9.0 was reported to us through the WooCommerce and WooCommerce Legacy REST API support forums. The issue appears to be the result between code associated to the recent deprecation of the Legacy REST API, server configurations, and caching mechanisms.

The primary symptom of this problem is a fatal error message stating Fatal error: Uncaught Error: Class 'WC_Legacy_API' not found... This error has been observed predominantly among users employing LiteSpeed Cache Plugin, although it may also impact others.

How Can I Tell If This Affects Me?

If you have upgraded to WooCommerce 9.0, and you encountered an error similar to the following: Fatal error: Uncaught Error: Class ‘WC_Legacy_API’ not found…, you are affected.

Error Message: Look for the specific fatal error message mentioned above in your WordPress error logs or directly on your website if errors are displayed to visitors.

Immediate Actions We Are Taking

We have implemented a temporary fix that prevents the fatal error from occurring (#48593). However, this does not address the root cause of why deleted files continue to appear on servers.

We are actively investigating the root cause in order to implement a permanent resolution to this issue. We will announce updates in this blog and across our social channels.

What Action Should I Take?

We suspect this issue is related with deleted files continuing to appear in the server as a result of a corrupted installation process.

  • For many users, manually removing the WooCommerce 9.0 plugin, and re-uploading the WooCommerce 9.0 plugin directory from the WooCommerce WordPress Plugin Page fixed the issue.
  • Users have also reported fixing the issue by installing WooCommerce 9.0 via wp-cli.
wp plugin deactivate woocommerce
wp plugin install woocommerce --version=9.0.0 --force
wp plugin activate woocommerce
wp plugin status woocommerce

If the fixes above do not stop the Fatal error: Uncaught Error: Class 'WC_Legacy_API' not found... error from appearing, please revert to WooCommerce 8.9.3

Still having issues? Please reach out to us in the comments section. 


23 responses to “Developer Advisory: Legacy REST API error in WooCommerce 9.0”

  1. Is this stuff even tested b4 it’s released? One problem after another lately.

    1. Hi Sandy!

      Thank you for the feedback. I know it can seem like a lot, but because our code is so customizable, such as in this scenario, we can’t test for every possible configuration. That said, it doesn’t mean we don’t want to help resolve an issue that may arise, and try to do so in a communicative way that works with our community.

  2. How do i revert to wocommerce 8.9.3?

    1. Shani Banerjee Avatar
      Shani Banerjee

      Hi Maria,

      You can use the WP rollback plugin, or the WP CLI:


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

      1. Actually, this won’t work if the error is still in effect, as that plugin uses AJAX to load it’s rollback screen, which crashes because of the fatal error.

  3. I tried upgrading to 4.9.0 today and it crashed my site, just as you have stated it would – even though I did not have Legacy API enabled. I had to reinstall v4.8.3 to bring the site live again.

    If I follow your instructions and manually delete the plugin, will I have to setup WooCommerce again from scratch?

    1. Hi there, if you delete the WooCommerce plugin, your data still remains stored in the database:
      https://woocommerce.com/document/installing-uninstalling-woocommerce/#uninstalling-woocommerce

      You would have to take additional steps to actually remove those from the database.

  4. help me my website is down

    1. Hi there, can you try upgrading the site manually or using the CLI as described above?

      You will need to download the latest zip of WooCommerce: https://downloads.wordpress.org/plugin/woocommerce.9.0.0.zip

      If you are able to access your admin page, navigate to “Plugins” > “Add New”, and upload the zip file of the new WooCommerce version you downloaded. Activate the plugin.

      If you are comfortable using the CLI, you can follow the commands listed above to update the version.

      1. For those having issue with the website down, this fixed it for me.
        1) follow the link in your email to go into the site’s wp-admin in recovery mode
        2) disable the legacy rest API plugin
        3) exit recovery mode
        4) download the woocommerce 9.0.0 from the link above
        5) install the zip file as a plugin, overwriting the existing 9.0.0 version
        6) re-enable the legacy rest API, and enable the woocommerce is disabled.
        your website should be back up and running (it was for me)

  5. ladytango Avatar
    ladytango

    All my sites are down…this is wild.

    1. Hi there, can you try to upgrade using the CLI or manually upgrade using the zip file?
      https://downloads.wordpress.org/plugin/woocommerce.9.0.0.zip

      This has fixed the issue for users. If you are still experiencing errors, we recommend you revert to 8.9.3:
      https://downloads.wordpress.org/plugin/woocommerce.8.9.3.zip

  6. I am pissed of to no end

  7. Pedro Ribeiro Avatar
    Pedro Ribeiro

    Bonjour,

    Merci beaucoup,
    Si on déactive LiteSpeed Cache Plugin, cela règle le probléme ?

    1. Hi Pedro, disabling LiteSpeed Cache Plugin will not fix the problem.

      You should be able to manually upload a zip file of version 9.0.0 and this should resolve the error. Alternatively, we are working on a fix that should be rolled out in the next few hours: https://downloads.wordpress.org/plugin/woocommerce.9.0.0.zip

  8. My Word Press site crashed two days ago, message: ‘There has been a critical error on this website.’

    I have tracked this down to the woocommerce update 9.0.0. The crash occurred at the same time as the upgrade.

    How can I fix the problem without losing all my woocommerce data, particularly product listings.

    By changing the name of the plugins folder to plugins_ I can get the parts of the website not requiring woocommerce to display.

    Any help, please

    1. Hi Scott, if you delete the WooCommerce plugin, your data still remains stored in the database:
      https://woocommerce.com/document/installing-uninstalling-woocommerce/#uninstalling-woocommerce

      You should be able to manually upload a zip file of version 9.0.0 and this should resolve the error. Alternatively, we are working on a fix that should be rolled out in the next few hours: https://downloads.wordpress.org/plugin/woocommerce.9.0.0.zip

  9. There’s been a fatal error with every update since roughly 8.8. Madness.

  10. Shani and any other WC team – presume Shani is?

    There are several things here.

    This “bug”, in many cases on the sites I support, just simply causes a “Critial Error”. Leading to the site not working at all!

    It’s far more major than you think.

    We have had to login to the dashboard using the “safe” option to even trouble shoot.

    It is not required or needed to use the WP-CLI.

    Using FTP or File Manager in cPanel rename the WC folder to something like woocommerce_do_not_use will show the plugin as inactive, but deleteable. Then delete the plugin. Then simply re-install and it seems to fix the issue.

    I do agree, though, that for a plugin from Automattic of this magnitude to be this faulty and not, initially, know the problem is a bit of a disaster.

    Nigel Stevenson on WP.org has been quick enough to try to help. Please read some threads there…..

    https://wordpress.org/support/plugin/woocommerce/

    Steve B

    1. Barry Hughes Avatar
      Barry Hughes

      It’s far more major than you think.

      No mistake, we understand how major this is.

      That for a plugin from Automattic of this magnitude to be this faulty and not, initially, know the problem.

      Perhaps I could add some thoughts on this.

      This was a very unusual situation and, since we’re still investigating the cause, our thoughts may change as the picture develops. However, at this point, it does not seem to be the direct result of a problem in the 9.0.0 release (which is why simply re-installing 9.0.0 often fixes things).

      Instead, the information we currently hold suggests that this is a problem in the way the update was performed in some hosting environments, leading to a corrupt or ‘dirty’ installation. If our theory is correct, this would have been near-impossible to detect in our own testing before release.

      I’m simplifying a little here but, left to its own devices, WordPress normally updates a plugin by replacing the old version with the new (that to say, no traces of the old version are left in situ) … whereas, for those impacted by this problem, that does not appear to be the case, and it may be that the update was initiated at some other level, by a tool other than WordPress, which could also explain why updates were automatically applied even to sites where automatic updates were disabled.

      The above is very provisional, though we are actively following up on a few leads that indicate we might be on the right track.

  11. To Scott….

    Normally deleting the 9.0.0 version will not remove/delete/destroy your products and any WC database….

    BUT. Presumably, like any sensible chappie, you are using a backup app? 🙂

    If so then you can be safe, and sure, that your data is protected.

    If you are not, there are several apps availabile to you. If you have your own server then there should be a back option in WHM….

    If you want some possible options let me know….

    Steve B

  12. Paul Burrows Avatar
    Paul Burrows

    Hi
    Can you please confirm if the latest release of 9.0.1 fixes the Fatal Error issue?
    Regards
    Paul B

    1. Hi Paul, upgrading to this version should solve the issues some users were experiencing with the launch of 9.0.

      The team has added one commit to this release specifically to deal with this problem. Please let us know if the issues are solved after upgrading.

Leave a Reply

Your email address will not be published. Required fields are marked *