WordPress at Your Fingertips
function is not described

WC_Checkout::send_ajax_failure_response() protected WC 1.0

If checkout failed during an AJAX call, send failure response.

{} It's a method of the class: WC_Checkout{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->send_ajax_failure_response();

Code of WC_Checkout::send_ajax_failure_response() WC 5.9.0

protected function send_ajax_failure_response() {
	if ( is_ajax() ) {
		// Only print notices if not reloading the checkout, otherwise they're lost in the page reload.
		if ( ! isset( WC()->session->reload_checkout ) ) {
			$messages = wc_print_notices( true );
		}

		$response = array(
			'result'   => 'failure',
			'messages' => isset( $messages ) ? $messages : '',
			'refresh'  => isset( WC()->session->refresh_totals ),
			'reload'   => isset( WC()->session->reload_checkout ),
		);

		unset( WC()->session->refresh_totals, WC()->session->reload_checkout );

		wp_send_json( $response );
	}
}