woocommerce_catalog_ordering

Output the product sorting options.

Description

woocommerce_catalog_ordering(); 

Usage

  1. if ( !function_exists( 'woocommerce_catalog_ordering' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = woocommerce_catalog_ordering(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-template-functions.php  
  1. function woocommerce_catalog_ordering() { 
  2. global $wp_query; 
  3.  
  4. if ( 1 === (int) $wp_query->found_posts || ! woocommerce_products_will_display() ) { 
  5. return; 
  6.  
  7. $orderby = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); 
  8. $show_default_orderby = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); 
  9. $catalog_orderby_options = apply_filters( 'woocommerce_catalog_orderby', array( 
  10. 'menu_order' => __( 'Default sorting', woocommerce ),  
  11. 'popularity' => __( 'Sort by popularity', woocommerce ),  
  12. 'rating' => __( 'Sort by average rating', woocommerce ),  
  13. 'date' => __( 'Sort by newness', woocommerce ),  
  14. 'price' => __( 'Sort by price: low to high', woocommerce ),  
  15. 'price-desc' => __( 'Sort by price: high to low', woocommerce ),  
  16. ) ); 
  17.  
  18. if ( ! $show_default_orderby ) { 
  19. unset( $catalog_orderby_options['menu_order'] ); 
  20.  
  21. if ( 'no' === get_option( 'woocommerce_enable_review_rating' ) ) { 
  22. unset( $catalog_orderby_options['rating'] ); 
  23.  
  24. wc_get_template( 'loop/orderby.php', array( 'catalog_orderby_options' => $catalog_orderby_options, 'orderby' => $orderby, 'show_default_orderby' => $show_default_orderby ) );