Only show default ordering option when relevant

Closes #5893
This commit is contained in:
Mike Jolley 2014-07-30 17:17:51 +01:00
parent b752f75392
commit cab8f8c9dd
2 changed files with 13 additions and 6 deletions

View File

@ -643,9 +643,10 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
* @return void
*/
function woocommerce_catalog_ordering() {
$orderby = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
$orderby = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
$show_default_orderby = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
wc_get_template( 'loop/orderby.php', array( 'orderby' => $orderby ) );
wc_get_template( 'loop/orderby.php', array( 'orderby' => $orderby, 'show_default_orderby' => $show_default_orderby ) );
}
}

View File

@ -4,7 +4,7 @@
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
* @version 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@ -26,11 +26,17 @@ if ( 1 == $wp_query->found_posts || ! woocommerce_products_will_display() )
'price-desc' => __( 'Sort by price: high to low', 'woocommerce' )
) );
if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' )
unset( $catalog_orderby['rating'] );
if ( ! $show_default_orderby ) {
unset( $catalog_orderby['menu_order'] );
}
foreach ( $catalog_orderby as $id => $name )
if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' ) {
unset( $catalog_orderby['rating'] );
}
foreach ( $catalog_orderby as $id => $name ) {
echo '<option value="' . esc_attr( $id ) . '" ' . selected( $orderby, $id, false ) . '>' . esc_attr( $name ) . '</option>';
}
?>
</select>
<?php