• 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 143

    It 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)
  • Plugin Support Janilyn T

    (@janilyn409)

    Hi @zendev ,

    Thanks for reporting this issue.

    I will write a report to our developers so that they can consider this in the next update of this plugin.

    Best regards.

    I am also experiencing a similar issue, with the error:
    POST https://domain.com/?wc-ajax=wpcsn 500 (Internal Server Error).

    It seems that @zendev’s assumption might be correct because I recently had an order that was canceled as well.

    Thread Starter zendev

    (@zendev)

    Wanted to report that the error remains unfixed in the latest version (Version 2.4.1). The fix for anybody seeing the error is either

    a) don’t let the most recent order be a cancelled order

    or

    b) Comment out line 143 and 144 of /wp-content/plugins/wpc-smart-notification/core/notification.php

    and then insert

    if ( $order instanceof WC_Order ) {
    $_name = $order->get_billing_first_name();
    $_address = $order->get_billing_city();
    } else {
    continue;
    }

    above what you commented out. You’ll have to do this again after updating the plugin until it’s fixed upstream.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.