HTTP 500 on calling /?wc-ajax=wpcsn
-
Possible bug report. I noticed that I was getting an HTTP 500 response in the browser’s network tab on calls to /?wc-ajax=wpcsn.
The WordPress debug log shows:
[10-Sep-2024 00:27:30 UTC] PHP Fatal error: Uncaught Error: Call to undefined method Automattic\WooCommerce\Admin\Overrides\OrderRefund::get_formatted_billing_full_name(); in /var/www/domain.com/wp-content/plugins/wpc-smart-notification/core/notification.php:143
Stack trace:
#0 /var/www/domain.com/wp-content/plugins/wpc-smart-notification/core/notification.php(26): WPCSN\notification->new_orders()
#1 /var/www/domain.com/wp-content/plugins/wpc-smart-notification/core/ajax-processing.php(19): WPCSN\notification->get_content()
#2 /var/www/domain.com/wp-includes/class-wp-hook.php(324): WPCSN\ajaxProcessing->get_content()
#3 /var/www/domain.com/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#4 /var/www/domain.com/wp-content/plugins/wpc-smart-notification/core/ajax-definition.php(25): apply_filters()
#5 /var/www/domain.com/wp-content/plugins/wpc-smart-notification/core/initialization.php(38): WPCSN\ajax->__construct()
#6 /var/www/domain.com/wp-includes/class-wp-hook.php(324): WPCSN\initialization->ajax()
#7 /var/www/domain.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#8 /var/www/domain.com/wp-includes/plugin.php(517): WP_Hook->do_action()
#9 /var/www/domain.com/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(96): do_action()
#10 /var/www/domain.com/wp-includes/class-wp-hook.php(324): WC_AJAX::do_wc_ajax()
#11 /var/www/domain.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#12 /var/www/domain.com/wp-includes/plugin.php(517): WP_Hook->do_action()
#13 /var/www/domain.com/wp-includes/template-loader.php(13): do_action()
#14 /var/www/domain.com/wp-blog-header.php(19): require_once('...')
#15 /var/www/domain.com/index.php(17): require('...')
#16 {main}
thrown in /var/www/domain.com/wp-content/plugins/wpc-smart-notification/core/notification.php on line 143It seems that if one of the orders returned was cancelled or refunded, an OrderRefund object is returned instead of an order object, which breaks the popup notification until there are no invalid objects returned.
Seems to be fixable by checking if the object returned is an WC_Order:
if ( $order instanceof WC_Order ) {
$_name = $order->get_formatted_billing_full_name();
$_address = $order->get_billing_city();
} else {
continue;
}Also, while I’m here, I wanted to suggest changing line 143 from:
$_name = $order->get_formatted_billing_full_name();
to:
$_name = $order->get_billing_first_name();
As customers may not with their full name to be displayed publicly.
Cheers!
Zendev
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.