How to Hide Errors From Visitors WooCommerce

WooCommerce Hide Errors From VisitorsIf you are familiar with WordPress, you know that it has a built-in debugging method that works well for developers. This method offers a warning message detailing what file is at fault and what line to look at in the code. However, if these errors appear on your WooCommerce store, they can easily dissuade visitors from coming back. Moreover, it looks extremely unprofessional when they are visible.

WooCommerce Hide Errors From Visitors

This brief tutorial will see how it is very easy to turn off PHP errors in your WooCommerce store.

What Causes PHP Error Messages

Outdated plugins and themes mostly cause PHP error messages. The core files will often change with WordPress updates, which make some parts of code obsolete.

Additionally, themes and plugins can also show PHP warning messages when used with incompatible something. Two different plugins can work well by themselves but have issues when paired together. This is because not all developers use the same syntax when developing website files.

However, some of these warnings do not necessarily mean that your site is broken. They do not look good to an unsuspecting visitor. The developer can create an update to fix the warning, but it takes a longer time.

PHP warning messages look like this:

“/wp-content/plugins/siteplugin.php on line 60”

This warning does not mean that the plugin is bad, but it means that part of the file is incompatible with WordPress, the theme, or another plugin that is in use.

However, you can fix the code by yourself, but it would probably be better to disable the warning messages. Moreover, if the tool is not entirely broken or unusable, then the warning may not completely apply to you.

Hiding PHP Warnings in WooCommerce.

This section involves customizing the wp-config.php file. I highly recommend that you create a backup of your site before making any changes to the code. This is a precautionary measure in the event something goes wrong. You can quickly restore your site.

Inside your wp-config.php file, look for the following line:

define('WP_DEBUG', true);

However, in some cases, it might be set to false:

define('WP_DEBUG', false);

In both cases, you need to replace this line with the following code:

ini_set('display_errors','Off');

ini_set('error_reporting', E_ALL );

define('WP_DEBUG', false);

define('WP_DEBUG_DISPLAY', false);

Remember to save your changes and upload your wp-config.php file back to the server.

The next step is to visit the front end to confirm that the PHP errors, notices, and warnings have disappeared.

Turning on PHP Errors in WooCommerce

To turn on PHP Errors, you need to edit your wp-config.php file. This is important if you are working on a website on a local server or staging area. To turn on error reporting, replace the code you added earlier with the following code:

define('WP_DEBUG', true);

define('WP_DEBUG_DISPLAY', true);

You will see the PHP errors, warnings, and notices again.

Conclusion

In summary, I have shared how to turn off WooCommerce errors. Outdated plugins and themes mainly cause them. They show PHP warning messages when they are used with something incompatible. Moreover, I have shown you how you can turn on the errors. Remember to be careful when editing the code in the wp-config.php file.

Similar Articles

  1. How to Add WooCommerce Storefront Hero Image