How to Fix WooCommerce Square Fatal Error – Error message: Uncaught Error: Call to undefined function Core\Utils\php_uname()

How to Fix WooCommerce Square Fatal Error - Error message: Uncaught Error: Call to undefined function Core\Utils\php_uname()

The WooCommerce Square plugin is a great way to enable customers to track the status of their orders through your website. However, if you’re finding problems with getting the plugin to show up after your plugin or theme update, or if you keep having this error: Uncaught Error: Call to undefined function Core\Utils\php_uname() when creating an order … then this video is for you! I’ll walk you through the process step by step, so don’t worry if you’re not familiar with file editing. Once you make the change, the error should stop being thrown. Keep in mind that you may need to repeat this process every time you update the plugin until the issue is fixed.

Error Code:

				
					Error Details
=============
An error of type E_ERROR was caused in line 159 of the file /var/www/wptbox/wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/Utils/CoreHelper.php. Error message: Uncaught Error: Call to undefined function Core\Utils\php_uname() in /var/www/wptbox/wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/Utils/CoreHelper.php:159
Stack trace:
# 0  wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/ClientBuilder.php(181): Core\Utils\CoreHelper::getOsInfo()
# 1  wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/ClientBuilder.php(195): Core\ClientBuilder->addUserAgentToGlobalHeaders()
# 2  wp-content/plugins/woocommerce-square/vendor/square/square/src/SquareClient.php(172): Core\ClientBuilder->build()
# 3  wp-content/plugins/woocommerce-square/includes/API.php(71): Square\SquareClient->__construct()
# 4  wp-content/plugins/woocommerce-square/includes/Gateway/API.php(55): WooCommerce\Square\API->__construct()
# 5  wp-content/plugins/woocommerce-square/includes/Gateway.php(1044): WooCommerce\Square\Gateway\API->__construct()
# 6  wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway_Plugin.php(588): WooCommerce\Square\Gateway->get_api()
# 7  wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway_Plugin.php(528): WooCommerce\Square\Framework\PaymentGateway\Payment_Gateway_Plugin->add_ssl_admin_notices()
# 8  wp-includes/class-wp-hook.php(308): WooCommerce\Square\Framework\PaymentGateway\Payment_Gateway_Plugin->add_delayed_admin_notices()
# 9  wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
# 10 wp-includes/plugin.php(517): WP_Hook->do_action()
# 11 wp-admin/admin-footer.php(78): do_action()
# 12 wp-admin/index.php(211): require_once('...')
# 13 {main}
thrown
				
			

Step by Step Guide:

  • Access the WordPress files. You can use a File Manager within your CPanel, or a FTP application like FileZilla.
  • Open the WordPress directory, and navigate to:
				
					wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/Utils/
				
			
  • Open the CoreHelper.php file to edit it. You can use the built-in file editor in CPanel, or an application like Notepad++
  • We are going to edit the function getOsInfo starting on line 154. Go to line 159 and change 
				
					return PHP_OS_FAMILY . '-' . php_uname('r');
				
			

to

				
					return '';
				
			
  • Save the changes, and you’re good to go!