WC_Checkout::send_ajax_failure_response()protectedWC 1.0

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

Метод класса: WC_Checkout{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->send_ajax_failure_response();

Код WC_Checkout::send_ajax_failure_response() WC 8.7.0

protected function send_ajax_failure_response() {
	if ( wp_doing_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 );
	}
}