WC_AJAX::do_wc_ajax()public staticWC 1.0

Check for WC Ajax request and fire action.

Method of the class: WC_AJAX{}

Hooks from the method

Return

null. Nothing (null).

Usage

$result = WC_AJAX::do_wc_ajax();

WC_AJAX::do_wc_ajax() code WC 9.4.2

public static function do_wc_ajax() {
	global $wp_query;

	// phpcs:disable WordPress.Security.NonceVerification.Recommended
	if ( ! empty( $_GET['wc-ajax'] ) ) {
		$wp_query->set( 'wc-ajax', sanitize_text_field( wp_unslash( $_GET['wc-ajax'] ) ) );
	}

	$action = $wp_query->get( 'wc-ajax' );

	if ( $action ) {
		self::wc_ajax_headers();
		$action = sanitize_text_field( $action );
		do_action( 'wc_ajax_' . $action );
		wp_die();
	}
	// phpcs:enable
}