• Resolved Machine IT Services

    (@machineitsvcs)


    I am getting the following fatal error when attempting to refund an order via the WooCommerce app. From what I can tell, the error is occuring when attempting to call method “set_status( 201 )” on the $response object on line 219, which is defined as a WP_Error, which is set by the prepare_object_for_response() function on line 217. If WP_Error does not have the set_status() method defined, then why are you attempting to call this method when prepare_object_for_response() only returns WP_Error objects? Also attempting to call the header() method on the same object on line 220, which is also undefined. Both lines 219 and 220 should only call those methods if they are instantiated for the object. Perhaps we can add a check for those methods or something to avoid the fatal error?

    PHP message: PHP Fatal error: Uncaught Error: Call to undefined method WP_Error::set_status() in /web/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php:219\nStack trace:\n#0 /web/wp-includes/rest-api/class-wp-rest-server.php(1141): WC_REST_CRUD_Controller->create_item()\n#1 /web/wp-includes/rest-api/class-wp-rest-server.php(988): WP_REST_Server->respond_to_request()\n#2 /web/wp-includes/rest-api/class-wp-rest-server.php(414): WP_REST_Server->dispatch()\n#3 /web/wp-includes/rest-api.php(386): WP_REST_Server->serve_request()\n#4 /web/wp-includes/class-wp-hook.php(311): rest_api_loaded()\n#5 /web/wp-includes/class-wp-hook.php(336): WP_Hook->apply_filters()\n#6 /web/wp-includes/plugin.php(522): WP_Hook->...

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Joash

    (@joashrajin)

    Hi @machineitsvcs ??

    Thanks for sharing this information with us. In order for us to get a better idea of your site setup, could you please share a copy of your site’s System Status? You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”.? Once you’ve done that, paste it here in your response.

    Once we have that, we should be able to investigate this matter more closely and see if we are able to replicate the error. Thanks!

    Thread Starter Machine IT Services

    (@machineitsvcs)

    I am unable to provide a System Report at this time. I feel like the information provided should be enough to look into this issue. Regardless, I found a workaround for the error for my use case, so feel free to close the ticket unless you wish to look into why these methods are being called on a WP_Error object at all.

    Hello,

    I found a workaround for the error for my use case, so feel free to close the ticket

    Next time you need to send the system status report, you can redact any sensitive information.

    Glad to know you figured this out.

    I’ll mark this thread as resolved now. If you have any further questions, I recommend creating a new thread. Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fatal Error when Refunding via WooCommerce App’ is closed to new replies.