If 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.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Create WooCommerce Secret Product
- How to Simplify Checkout Free Items Storefront Theme
- How to Add WooCommerce Storefront Product Pagination
- How to Hide Empty Category In WooCommerce
- How to Add WooCommerce Storefront Sitemap
- How to Hide Price When Out of Stock In WooCommerce
- How to Remove Has Been Added to Your Cart Message WooCommerce
- How to Redirect a WordPress Page Without Plugins?
- How to Add a Sidebar to WordPress » Ultimate Step-by-Step Guide
- How to Create Custom Widget Area in WordPress Step by Step
- How to Redirect User If Not Logged in WordPress » Page Redirect
- How to Add Text Before the Price in WooCommerce » Add Text Before Price
- How to Fix WooCommerce Storefront Theme Internal 500 Server Error
- How to Display Error Messages in WordPress: Debug WordPress Errors Quickly & Easily
- How to Logout without Confirmation WooCommerce: How to Remove “Are you sure you want to log out?”
- How to Fix – Warning: An Existing WordPress Network was Detected
- How to Create Number Pagination in WordPress Without Using Plugin
- How to Add WooCommerce Storefront Hero Image