WC_AJAX::add_ajax_events()public staticWC 1.0

Hook in methods - uses WordPress ajax handlers (admin-ajax).

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

Хуков нет.

Возвращает

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

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

$result = WC_AJAX::add_ajax_events();

Код WC_AJAX::add_ajax_events() WC 8.7.0

public static function add_ajax_events() {
	$ajax_events_nopriv = array(
		'get_refreshed_fragments',
		'apply_coupon',
		'remove_coupon',
		'update_shipping_method',
		'get_cart_totals',
		'update_order_review',
		'add_to_cart',
		'remove_from_cart',
		'checkout',
		'get_variation',
		'get_customer_location',
	);

	foreach ( $ajax_events_nopriv as $ajax_event ) {
		add_action( 'wp_ajax_woocommerce_' . $ajax_event, array( __CLASS__, $ajax_event ) );
		add_action( 'wp_ajax_nopriv_woocommerce_' . $ajax_event, array( __CLASS__, $ajax_event ) );

		// WC AJAX can be used for frontend ajax requests.
		add_action( 'wc_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
	}

	$ajax_events = array(
		'feature_product',
		'mark_order_status',
		'get_order_details',
		'add_attribute',
		'add_new_attribute',
		'remove_variations',
		'save_attributes',
		'add_attributes_and_variations',
		'add_variation',
		'link_all_variations',
		'revoke_access_to_download',
		'grant_access_to_download',
		'get_customer_details',
		'add_order_item',
		'add_order_fee',
		'add_order_shipping',
		'add_order_tax',
		'add_coupon_discount',
		'remove_order_coupon',
		'remove_order_item',
		'remove_order_tax',
		'calc_line_taxes',
		'save_order_items',
		'load_order_items',
		'add_order_note',
		'delete_order_note',
		'json_search_products',
		'json_search_products_and_variations',
		'json_search_downloadable_products_and_variations',
		'json_search_customers',
		'json_search_categories',
		'json_search_categories_tree',
		'json_search_taxonomy_terms',
		'json_search_product_attributes',
		'json_search_pages',
		'term_ordering',
		'product_ordering',
		'refund_line_items',
		'delete_refund',
		'rated',
		'update_api_key',
		'load_variations',
		'save_variations',
		'bulk_edit_variations',
		'tax_rates_save_changes',
		'shipping_zones_save_changes',
		'shipping_zone_add_method',
		'shipping_zone_remove_method',
		'shipping_zone_methods_save_changes',
		'shipping_zone_methods_save_settings',
		'shipping_classes_save_changes',
		'toggle_gateway_enabled',
	);

	foreach ( $ajax_events as $ajax_event ) {
		add_action( 'wp_ajax_woocommerce_' . $ajax_event, array( __CLASS__, $ajax_event ) );
	}

	$ajax_private_events = array(
		'order_add_meta',
		'order_delete_meta',
	);

	foreach ( $ajax_private_events as $ajax_event ) {
		add_action(
			'wp_ajax_woocommerce_' . $ajax_event,
			function() use ( $ajax_event ) {
				call_user_func( array( __CLASS__, $ajax_event ) );
			}
		);
	}

	// WP's heartbeat.
	$ajax_heartbeat_callbacks = array(
		'order_refresh_lock',
		'check_locked_orders',
	);
	foreach ( $ajax_heartbeat_callbacks as $ajax_callback ) {
		add_filter(
			'heartbeat_received',
			function( $response, $data ) use ( $ajax_callback ) {
				return call_user_func_array( array( __CLASS__, $ajax_callback ), func_get_args() );
			},
			11,
			2
		);
	}
}