woocommerce_result_count()WC 1.0

Output the result count text (Showing x - x of x results).

Return

null. Nothing (null).

Usage

woocommerce_result_count();

woocommerce_result_count() code WC 9.7.1

function woocommerce_result_count() {
	if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) {
		return;
	}

	/**
	 * Filters the default orderby option.
	 *
	 * @since 1.6.4
	 *
	 * @param string  $default_orderby The default orderby option.
	 */
	$default_orderby = apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', '' ) );
	// phpcs:ignore WordPress.Security.NonceVerification.Recommended
	$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : $default_orderby;

	// If products follow the default order this doesn't need to be informed.
	$orderby = 'menu_order' === $orderby ? '' : $orderby;

	$orderby = is_string( $orderby ) ? $orderby : '';

	/**
	 * Filters ordered by messages.
	 *
	 * @since 9.3.0
	 *
	 * @param array  $orderedby_messages The list of messages per orderby key.
	 */
	$catalog_orderedby_options = apply_filters(
		'woocommerce_catalog_orderedby',
		array(
			'menu_order' => __( 'Default sorting', 'woocommerce' ),
			'popularity' => __( 'Sorted by popularity', 'woocommerce' ),
			'rating'     => __( 'Sorted by average rating', 'woocommerce' ),
			'date'       => __( 'Sorted by latest', 'woocommerce' ),
			'price'      => __( 'Sorted by price: low to high', 'woocommerce' ),
			'price-desc' => __( 'Sorted by price: high to low', 'woocommerce' ),
		)
	);
	$orderedby                 = isset( $catalog_orderedby_options[ $orderby ] ) ? $catalog_orderedby_options[ $orderby ] : '';
	$orderedby                 = is_string( $orderedby ) ? $orderedby : '';
	$args                      = array(
		'total'     => wc_get_loop_prop( 'total' ),
		'per_page'  => wc_get_loop_prop( 'per_page' ),
		'current'   => wc_get_loop_prop( 'current_page' ),
		'orderedby' => $orderedby,
	);

	wc_get_template( 'loop/result-count.php', $args );
}