We are using the toolset plugin to create custom fields and post types for our e-comm website. We sell subscription products usign WooCommerce Subscription Plugin. We also use https://woocommerce.com/products/automatewoo/ by woocommerce in order to automate our marketing tasks.. During one of our renewal process, we found the log of an array.
Unexpected shutdown: PHP Fatal error Uncaught Error: Call to undefined function wc_get_notices() in /var/www/html/wp-content/toolset-customizations/functions-codes.php:66 Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(289): houx_filter_wc_notices('emails/email-he...') #1 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array) #2 /var/www/html/wp-includes/plugin.php(478): WP_Hook->do_action(Array) #3 /var/www/html/wp-content/plugins/automatewoo/includes/Mailer.php(328): do_action('woocommerce_bef...', 'emails/email-he...', '', '/var/www/html/w...', Array) #4 /var/www/html/wp-content/plugins/automatewoo/includes/Mailer.php(153): AutomateWoo\Mailer->get_template_part('email-header.ph...', Array) #5 /var/www/html/wp-content/plugins/automatewoo/includes/Mailer.php(131): AutomateWoo\Mailer->get_content_wrapped_in_template() #6 /var/www/html/wp-content/plugins/automatewoo/includes/Mailer_Abstract.php(198): AutomateWoo\Mailer->get_email_body() #7 /var/www/html/wp-content/plugins/automatewoo/includes/Workflow_Emai in /var/www/html/wp-content/toolset-customizations/functions-codes.php on line 66
Which prevented the automatic email from being triggered. Can you please look into this ?
Can you please look into this ?
Hello, if I'm reading the error correctly, it looks like a custom code snippet that was placed in the Toolset > Settings > Custom Code tab includes a call to the WooCommerce function wc_get_notices:
PHP Fatal error Uncaught Error: Call to undefined function wc_get_notices() in /var/www/html/wp-content/toolset-customizations/functions-codes.php:66
The error message indicates this function is included in the snippet functions-codes on line 66. The function wc_get_notices is a documented API function in WooCommerce (see below), so it's unusual to get an undefined error. Maybe your custom code is triggered before the WC function wc_get_notices is initialized, or maybe there is some other issue? Hard for me to say given the information I have at hand. What can you tell me about this custom code? Can you share the complete snippet here in your next reply? See "Formatting instructions" at the top of this input box for information about sharing code sippets so they are properly formatted and legible.
Regardless of the reason for the function being unavailable at the time it is called in your custom code, it can't hurt to check to see if wc_get_notices is actually a function before calling it. You could use PHP's function_exists function to wrap your call to wp_get_notices in a conditional, something like this:
if( function_exists('wc_get_notices') ) {
$notices = wc_get_notices();
// do something with $notices here
}
While this will prevent an undefined function call, it may not be the complete solution if you need to do something with the $notices array.
WC API Docs for wc_get_notices(): https://woocommerce.github.io/code-reference/namespaces/default.html#function_wc_get_notices