WC_Shop_Customizer::sanitize_default_catalog_orderby()publicWC 1.0

Sanitize the catalog orderby setting.

Method of the class: WC_Shop_Customizer{}

Return

String.

Usage

$WC_Shop_Customizer = new WC_Shop_Customizer();
$WC_Shop_Customizer->sanitize_default_catalog_orderby( $value );
$value(string) (required)
An array key from the below array.

WC_Shop_Customizer::sanitize_default_catalog_orderby() code WC 9.4.2

public function sanitize_default_catalog_orderby( $value ) {
	/* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
	$options = apply_filters(
		'woocommerce_default_catalog_orderby_options',
		array(
			'menu_order' => __( 'Default sorting (custom ordering + name)', 'woocommerce' ),
			'popularity' => __( 'Popularity (sales)', 'woocommerce' ),
			'rating'     => __( 'Average rating', 'woocommerce' ),
			'date'       => __( 'Sort by most recent', 'woocommerce' ),
			'price'      => __( 'Sort by price (asc)', 'woocommerce' ),
			'price-desc' => __( 'Sort by price (desc)', 'woocommerce' ),
		)
	);

	return array_key_exists( $value, $options ) ? $value : 'menu_order';
}